opencog / asmoses

MOSES Machine Learning: Meta-Optimizing Semantic Evolutionary Search for the AtomSpace (https://github.com/opencog/atomspace)

Home Page:https://wiki.opencog.org/w/Meta-Optimizing_Semantic_Evolutionary_Search

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Port Reduct

kasimebrahim opened this issue · comments

commented

As suggested in issue #3, In order to proceed to porting other subsystems we choose to wrap the existing Combo reduct engine.
Given a program P to be reduced, first we want to convert P to a combo::tree CP and reduce it using reduct to CP_reduced then convert it back to Atomese P_reduced.
Finally we need to store it in ReductLink, ReductLink can be

 REDUCT_LINK <- ORDERED_LINK "ReductLink"
(ReductLink
    (Schema "Rule")
    (Schema "P")
    (Schema "P_reduced"))

or just

(ReductLink
    (Schema "P")
    (Schema "P_reduced"))
commented

I think according to issue #3 , it is

(ReductLink
  (And
    (Predicate "f1")
    (Predicate "f1"))
  (Predicate "f1")))

Several remarks:

  • A portion of ReductLink has already been implemented; it is here: atomspace/opencog/atoms/reduct It only does the arithmetic links (plus, minus, times, divide)

  • It is implemented in C++ After implementing it in C++ I realized that this was just crazy and hard and inefficient and a totally untenable long-term strategy.

  • I'm not just expressing some idle opinion -- just look at the grunge that is moses reduct! Its huge, complicated, and porting/debugging that as C++ code would be insane.

  • So, instead, the proposal is to replace moses reduct by atomspace rules, as a bunch of bind-links: viz "IF this pattern matches THEN output a reduced pattern". Then run all of these rules over and over, in a loop, until not a single one of them matches any more. At that point, the reduction is done.

  • Its possible that maybe the ForwardChainer can run the above loop (ask @ngeiswei to be sure)

  • The above is the practice. The theory is that reduct is a kind-of-abstract term-rewriting-system. A simple one. The rules are just the rewrite rules of arithmetic (e.g. (x+0) reduces to x) and the rules of propositional logic (e.g. (y and True) reduces to y) The idea is that, by looping over and over on the rules, one continues until one has reached a "normal form" that cannot be reduced any further. See https://en.wikipedia.org/wiki/Normal_form_(abstract_rewriting) and https://en.wikipedia.org/wiki/Abstract_rewriting_system

  • By writing the rules in the atomspace, instead of hard-coding them in C++, you get to add other kinds of algebras to the system (there is much much much more to the world than just the axioms of arithmetic, and the axioms of propositional logic!!)

The upshot is -- you do not need ReductLink. You just need to write some reduction rules, and let the pattern matcher do the job it was designed to do.

Yes, this is easy to say, and maybe harder to do. You should start out by writing few simple rules, and see how it goes. I'm here to help.

@linas,

ReductLink
   A
   B

would not reduce but just indicate that expression B is reduced form of expression A.

We need to keep track of that because some reductions are defined recursively, such "if B1 is the reduced form of A1 and B2 is the reduced form of A2, then D = blahblah of B1 and B2 is the reduced form of C = blahblah of A1 and A2".

The plan is indeed to have the URE performs the reduction (forward and backward chainer should be possible).

The ReductLink name is not set in stone, just till we find the actual name. The fact that it trumped you indicates we do need a better one. Note that we don't need a new link type we can use

Evaluation
  Predicate "is-reduction-of"
  List
    A
    B

but since it is gonna be used quite extensively a dedicated link sounds appropriate, though for starter we can probably go with an EvaluationLink.

Maybe a better link name would be ReducedToLink.

OH, OK. I'm pretty certain you want to assign them to named classes, and limit reduct so that it works only with the provided classes (instead of any old link it can find in the atomspace). The classic moses ones were "arithmetic" and "propositional logic". but there are many more: "linear algebra" is popular for "linear programming problems", and integer algebras are popular for "discrete linear programming", and then there are dozens? hundreds? of different kinds of modal logics, each with it's own set of reduction rules.

See also issue #66 for more about arithmetic functions