Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storing PLN formulas in the AtomSpace #2015

Merged
merged 28 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8f88508
Add StrengthOf, ConfidenceOf link types.
linas Jan 26, 2019
5e22c73
Enable multiple library constructors
linas Jan 26, 2019
3af45f6
Convert FloatValues into TV's
linas Jan 26, 2019
db3ceee
Also evaluate outside of the EvluationLink
linas Jan 26, 2019
3ec2042
Allow numbers as well.
linas Jan 26, 2019
b984b1a
Allow Lambda for the forumlas.
linas Jan 26, 2019
740c426
Enable just ordinary formulas.
linas Jan 26, 2019
1edeef7
Add documentation
linas Jan 26, 2019
a77d373
More documentatiion
linas Jan 26, 2019
10c7c2d
Bug-fix handling of variables
linas Jan 27, 2019
6c6dd2e
Merge branch 'master' into vc
linas Jan 27, 2019
7b94317
Additional examples
linas Jan 27, 2019
d62caf8
Bug fix for PutLink
linas Jan 27, 2019
70ef6c8
One last bugfix for the demo
linas Jan 27, 2019
533f026
Expand the demo some more
linas Jan 27, 2019
5a509b8
Another bugfix
linas Jan 28, 2019
8ac829e
Start creating a unit test.
linas Jan 28, 2019
815f696
Extened the unit test
linas Jan 28, 2019
11c0ae9
Continue work on new unit test
linas Jan 28, 2019
87911ad
Expand unit test
linas Jan 28, 2019
d39e809
Last of the unit test expansion
linas Jan 28, 2019
f33ee7c
Allow DefinedPredicate to work, also
linas Jan 28, 2019
b92dc2e
Expand unit test for DefinedPrediate
linas Jan 28, 2019
ebb2281
Move a big block of code
linas Jan 28, 2019
01b4698
Cleanup for readability
linas Jan 28, 2019
37b090a
Use the correct exception type.
linas Jan 28, 2019
913d2ec
Wrap up the silent exceptions.
linas Jan 28, 2019
a552cff
The exceptions here will never be silent.
linas Jan 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions examples/atomspace/formulas.scm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

(cog-execute! (StrengthOf (Concept "A" (stv 0.8 1.0))))

(Concept "B" (stv 0.6 1.0))
(Concept "B" (stv 0.6 0.9))

(cog-execute!
(TimesLink (StrengthOf (Concept "A")) (StrengthOf (Concept "B"))))
Expand All @@ -18,14 +18,15 @@
(TimesLink (StrengthOf (Concept "A")) (StrengthOf (Concept "B")))
(TimesLink (ConfidenceOf (Concept "A")) (ConfidenceOf (Concept "B")))))

(EvaluationLink
(PredicateFormulaLink
(TimesLink
(StrengthOf (Concept "A"))
(StrengthOf (Concept "B")))
(List
(Concept "A")
(Concept "B")))
(cog-evaluate!
(PredicateFormulaLink (Number 0.7) (Number 0.314))
linas marked this conversation as resolved.
Show resolved Hide resolved

(cog-evaluate!
(EvaluationLink
(PredicateFormulaLink (Number 0.7) (Number 0.314))
(List
(Concept "A")
(Concept "B"))))

(EvaluationLink
(TimesLink (StrengthOf (Variable "$A") (Variable "$B")))
10 changes: 10 additions & 0 deletions opencog/atoms/execution/EvaluationLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,11 @@ TruthValuePtr EvaluationLink::do_eval_scratch(AtomSpace* as,
std::vector<double> nums;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this block of code also be replaced by do_formula() call?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. Let me look. I think it can be simpler, because it has no variables.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to keep as-is; to avoid passing in an empty list of arguments

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It is not clear for me why list of arguments is empty here? Is it correct that do_eval_scratch is called only after variables substitution?
  2. What is wrong with passing empty list of arguments if this will reduce the code bloat?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Yes, do_eval_scratch is called after argument substitution and reduction has been made. (There is a mostly-finished "lazy execution" code path that is unused because GPN/GSN's don't know how to be lazy. Hmm. I should look at that again.

  2. Yes, you are right. The two code paths are similar, one is longer and more complicated. The decision to merge them seems very close to being a coin-flip; there are benefits and disadvantages, they seem to cancel each out out.

for (const Handle& h: evelnk->getOutgoingSet())
{
if (NUMBER_NODE == h->get_type())
{
nums.push_back(NumberNodeCast(h)->get_value());
continue;
}
if (not nameserver().isA(h->get_type(), FUNCTION_LINK))
throw NotEvaluatableException();
ValuePtr v(FunctionLinkCast(h)->execute());
Expand Down Expand Up @@ -637,6 +642,11 @@ TruthValuePtr EvaluationLink::do_evaluate(AtomSpace* as,
std::vector<double> nums;
for (const Handle& h: pn->getOutgoingSet())
{
if (NUMBER_NODE == h->get_type())
{
nums.push_back(NumberNodeCast(h)->get_value());
continue;
}
if (not nameserver().isA(h->get_type(), FUNCTION_LINK))
throw NotEvaluatableException();
ValuePtr v(FunctionLinkCast(h)->execute());
Expand Down