Code Monkey home page Code Monkey logo

pln's Introduction

Probabilistic Logic Network

opencog singnet
CircleCI CircleCI

Probabilistic Logic Network, or PLN for short, is a logic invented by Ben Goertzel et al [1] for common sense reasoning. It is particularily well suited for uncertain reasoning, especially when knowledge is based on limited observations from reality, but can also handle abstract mathematical reasoning, and the relationship between the two.

To handle uncertainty PLN represents truth as a second order distribution, i.e. a probabilistic distribution over probabilistic distributions. Doing so allows to capture uncertainty while remaining in the well known and proven framework of probability theory.

PLN is no longer maintained

The lead developer has walked away from the project.

Building and Installing

Prequisite

Building PLN

# Download PLN
git clone https://github.com/opencog/pln.git

# Move to its project folder
cd pln

# Build with CMake
mkdir build
cd build
cmake ..
make -j

Installing PLN

After building, you must install PLN

sudo make install

Running ldconfig might required as well

ldconfig /usr/local/lib/opencog

Usage

The easiest way to use PLN is via its scheme bindings. For that enter

guile

load the PLN module

(use-modules (opencog pln))

then load PLN rules with functions pln-load, and run the forward and backward chainers with pln-fc and pln-bc. More help can be found in guile's online help (help pln-load), (help pln-fc) and (help pln-bc).

More usage information can be found in

opencog/pln/README.md

Examples

PLN examples can be found under the examples/pln directory. In particular the following examples use the pln module

The other examples can be informative but directly use the URE and thus are less user friendly.

pln's People

Contributors

alex-van-der-peet avatar amebel avatar chenesan avatar czhedu avatar edajade avatar eddiemonroe avatar ferrouswheel avatar githart avatar hedayat avatar huangdeheng avatar inflector avatar keyvan-m-sadeghi avatar leungmanhin avatar linas avatar misgeatgit avatar ngeiswei avatar noskill avatar prateeksaxena2809 avatar rekino avatar roman-khimov avatar rtreutlein avatar sebastianruder avatar shujingke avatar themixed avatar tnick avatar tpsjr7 avatar vsbogd avatar williampma avatar xiaohui avatar yantrabuddhi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pln's Issues

Use Atomese Formulas, and not scheme, for math

Friendly reminder, because I think it has fallen off the TODO-list. The new atomese formula support is likely to be a lot faster than using (GroundedPredicateNode "scm:foo-formula") See https://github.com/opencog/atomspace/blob/master/examples/atomspace/formulas.scm for a working example; I copy part of it below to give a flavor of it:

; Create a SimpleTruthValue with a non-trivial formula:
; It will be the TV := (1-sA*sB, cA*cB) where sA and sB are strenghts
; and cA, cB are confidence values. The PredicateFormulaLink assembles
; two floating-point values, and create a SimpleTruthValue out of them.
;
(cog-evaluate!
   (PredicateFormula
      (Minus
         (Number 1)
         (Times (StrengthOf (Concept "A")) (StrengthOf (Concept "B"))))
      (Times (ConfidenceOf (Concept "A")) (ConfidenceOf (Concept "B")))))

; The values do not need to be formulas; they can be hard-coded numbers.
(cog-evaluate!
   (PredicateFormula (Number 0.7) (Number 0.314)))

; The below computes a truth value, and attaches it to the
; EvaluationLink. Let's demo this in three parts: first define it,
; then evaluate it, then look at it.
;
(define my-ev-link
   (Evaluation
      (PredicateFormula (Number 0.7) (Number 0.314))
      (List
         (Concept "A")
         (Concept "B"))))

; Evaluate ...
(cog-evaluate! my-ev-link)

; Print.
(display my-ev-link)

; More typically, one wishes to have a formula in the abstract,
; with variables in it, so that one can apply it in any one of
; a number of different situations. In the below, the variables
; are automatically reduced with the Atoms in the ListLink, and
; then the formula is evaluated to obtain a TruthValue.
(cog-evaluate!
   (Evaluation
      ; Compute TV = (1-sA*sB, cA*cB)
      (PredicateFormula
         (Minus
            (Number 1)
            (Times
               (StrengthOf (Variable "$X"))
               (StrengthOf (Variable "$Y"))))
         (Times
            (ConfidenceOf (Variable "$X"))
            (ConfidenceOf (Variable "$Y"))))
      (List
         (Concept "A")
         (Concept "B"))))

and so on. The example gives even more details that make it even more PLN-useful.

Problems with implication-scope-to-implication-rule

I have been thinking about ImplicationScope to Implication conversion (and the reverse) and found some issues.

Let's say we have:

(ImplicationScopeLink (stv 1.0 1.0)
  (VariableList
    (VariableNode "$A")
    (VariableNode "$B"))
  (EvaluationLink
    (PredicateNode "does")
    (ListLink
      (VariableNode "$A")
      (VariableNode "$B")))
  (EvaluationLink
    (PredicateNode "isbeingdone")
    (VariableNode "$B")))

(ImplicationScopeLink (stv 1.0 1.0)
  (VariableList
    (VariableNode "$A"))
  (EvaluationLink
    (PredicateNode "isbeingdone")
    (VariableNode "$A"))
  (EvaluationLink
    (PredicateNode "willbedone")
    (VariableNode "$A")))

It seems reasonable to think that we can infer the following:

(ImplicationScopeLink (stv 1.0 1.0)
  (VariableList
    (VariableNode "$A")
    (VariableNode "$B"))
  (EvaluationLink
    (PredicateNode "does")
    (ListLink
      (VariableNode "$A")
      (VariableNode "$B")))
  (EvaluationLink
    (PredicateNode "willbedone")
    (VariableNode "$B")))

But atm this does not work. Let's try to do it and see where we fail. First we will have to use the implication-scope-to-implication-rule as the deduction-implication-rule we want to use only works on normal ImplicationLinks. This results in the following:

   (ImplicationLink (stv 1 1)
      (LambdaLink
         (VariableList
            (VariableNode "$A")
            (VariableNode "$B"))
         (EvaluationLink
            (PredicateNode "does")
            (ListLink
               (VariableNode "$A")
               (VariableNode "$B"))))
      (LambdaLink
         (VariableList
            (VariableNode "$A")
            (VariableNode "$B"))
         (EvaluationLink
            (PredicateNode "isbeingdone")
            (VariableNode "$B"))))

   (ImplicationLink (stv 1 1)
      (LambdaLink
         (VariableList
            (VariableNode "$A"))
         (EvaluationLink
            (PredicateNode "isbeingdone")
            (VariableNode "$A")))
      (LambdaLink
         (VariableList
            (VariableNode "$A"))
         (EvaluationLink
            (PredicateNode "willbedone")
            (VariableNode "$A"))))

And here we can see the issue. Namely that the LambdaLink wrapping the "isbeingdone" Predicate has 2 variables in one case and 1 in the other which stops the decuction-implication-rule from doing anything.
And if I understand this correctly can't change the implication-scope-to-implication-rule to just drop the extra Variable as that would break the equivalence between ImplicationScopeLink and the ImplicationLink.
So i think the correct solution would be to create a decuction-implication-scope-rule that can handle ImplicationScopeLinks by doing unification to get the mappings between variables and then using alpha-conversion to get 2 Links where the Variables Names line up correctly and then doing normal deduction.

Introduce arbitrary union atom type

Proposal

It would be convenient to have a link for the following

https://en.wikipedia.org/wiki/Union_(set_theory)#Arbitrary_unions

I suggest to call it

UnionLink

I like the compactness of it, however it could be mistaken for an OrLink, so maybe another name such as

ArbitraryUnionLink
ConceptUnionLink
ClassUnionLink
SetUnionLink
CountableUnionLink
FlattenLink
FlattenUnionLink

would be better (@bgoertzel, @linas or others let me know what you think).

The other alternative is to not introduce anything and instead formulate such union with a SatisfyingSetScopeLink, but I think it's rather cumbersome.

Motivation

Intensional reasoning relies on an ontology of concepts and their subset relationships. However sometimes concepts themselves have properties, i.e. be members of other classes, and we need a way to bring these meta-properties to the mesa-level.

For instance given an ontology of concepts C1, ..., Cn, and some meta-property M, such that some Ci, ..., Ck are a members of M

(Member Ci M)
...
(Member Ck M)

We'd like to bring the meta-property M into the ontology as a pattern to consider for intensional reasoning. One way to do that is to flatten M, with the following

(UnionLink M)

then we can write

(Subset C1 (UnionLink M))

Remark

It is expected such flattening would be especially useful if the meta-property is Soggy https://wiki.opencog.org/w/Soggy_Predicates as otherwise it might lose information when transferred to the mesa-level. Think for instance of a meta-property such as "even cardinality" which could encompass the whole mesa-universe and thus lose all information once flattened.

PS Remark

This issue is making me wonder whether the notion of membership is desirable at all. Maybe one can substitute membership for atomic inheritance, i.e. a concept that can no longer be divided. That's consistent with the definition of a probability measure.

TemporalReasoningUTest failures

Nil,

TemporalReasoningUTest is failing after what should have been a trivial change to the AtomSpace. It passes on this commit: 78b7f37a7c18b244a9e55d91054ddc5857e6a2cb and it fails on the next one: 5848cde3ddc46279a26e413e846c8018880cebb0 The only difference between these two commits are that five new atom types were added. I can't imagine why adding some more Atom types causes TemporalReasoningUTest to fail.

More precisely, it hangs and spins -- it eats CPU time, but makes no forward progress. The last thing it prints is this:

[DEBUG] [URE] Selected and-BIT for fulfillment (fcs value):
[ac47efeeeec27302][4]

and then hangs.

Strange PLN output

I am confused with application of this https://github.com/opencog/opencog/blob/master/opencog/reasoning/RuleEngine/rules/pln/contextualize.scm#L214

guile >(clear) (load-scm-from-file "/home/misgana/OPENCOG/opencog/opencog/python/pln/examples/deduction/atomspace_contents.scm")
guile>(load-scm-from-file "/home/misgana/OPENCOG/opencog/opencog/reasoning/RuleEngine/rules/pln/contextualize.scm")
guile>(cog-bind pln-rule-create-and-as-2nd-arg-of-inheritance)
(ListLink
   (InheritanceLink
      (ConceptNode "Animal" (stv 0.1 0.111111))
      (AndLink
         (ConceptNode "Being" (stv 0.1 0.111111))
         (ConceptNode "Being" (stv 0.1 0.111111))
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (ConceptNode "Animal" (stv 0.1 0.111111))
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
         (ConceptNode "Animal" (stv 0.1 0.111111))
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Animal" (stv 0.1 0.111111))
         (ConceptNode "Animal" (stv 0.1 0.111111))
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
         (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
         (ConceptNode "Animal" (stv 0.1 0.111111))
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
         (AndLink
            (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
            (ConceptNode "Animal" (stv 0.1 0.111111))
         )
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
         (AndLink
            (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
            (ConceptNode "Animal" (stv 0.1 0.111111))
         )
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
         (AndLink
            (ConceptNode "Animal" (stv 0.1 0.111111))
            (ConceptNode "Animal" (stv 0.1 0.111111))
         )
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (ConceptNode "Animal" (stv 0.1 0.111111))
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (AndLink
            (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
            (ConceptNode "Animal" (stv 0.1 0.111111))
         )
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (AndLink
            (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
            (ConceptNode "Animal" (stv 0.1 0.111111))
         )
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (AndLink
            (ConceptNode "Animal" (stv 0.1 0.111111))
            (ConceptNode "Animal" (stv 0.1 0.111111))
         )
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (AndLink
            (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
            (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
         )
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (AndLink
            (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
            (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
         )
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (AndLink
            (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
            (AndLink
               (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
               (ConceptNode "Animal" (stv 0.1 0.111111))
            )
         )
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (AndLink
            (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
            (AndLink
               (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
               (ConceptNode "Animal" (stv 0.1 0.111111))
            )
         )
      )
   )
   (InheritanceLink
      (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      (AndLink
         (ConceptNode "Intelligent" (stv 0.050000001 0.111111))
         (AndLink
            (ConceptNode "Slimy" (stv 0.0099999998 0.111111))
            (AndLink
               (ConceptNode "Animal" (stv 0.1 0.111111))
               (ConceptNode "Animal" (stv 0.1 0.111111))
            )
         )
      )
   )
   (InheritanceLink
      (ConceptNode "Peter" (stv 0.001 0.111111))
      (AndLink
         (ConceptNode "Frog" (stv 0.0099999998 0.111111))
         (ConceptNode "Frog" (stv 0.0099999998 0.111111))
      )
   )
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.