(use-modules (opencog) (opencog logger) (opencog exec) (opencog ure))
(define rbs (Concept "foo"))
(ure-set-maximum-iterations rbs 30)
(load-from-path "/home/rasberry/git/pln/opencog/pln/rules/propositional/crisp-conjunction-introduction.scm")
(Member (DefinedSchema "true-conjunction-introduction-2ary-rule") rbs)
(cog-logger-set-level! (cog-ure-logger) "debug")
(cog-logger-set-stdout! (cog-ure-logger) #t)
(define true (Concept "true"))
(define false (Concept "false"))
(define hungry (Concept "hungry"))
(define thirsty (Concept "thirty"))
(define alice (Concept "alice"))
(State (stv 1.0 1.0) (List alice hungry) true)
(State (stv 1.0 1.0) (List alice thirsty) false)
(define variables (VariableList
(TypedVariable
(Variable "person")
(Type "ConceptNode"))))
; NOTE: These returns (SetLink ) as they should, alice isnt thirsty, the second StateLink is evaluated correctly.
; (define target (And (State (List (Variable "person") hungry) true)
; (State (List (Variable "person") thirsty) true)))
; (cog-bc rbs target #:vardecl variables)
; (cog-execute! (Get variables target))
; NOTE: This doesnt evaluate the grounded second state and that ends up with an erroneous (stv 1.0 0.0) instead of (stv 0.0 1.0) which follows from the existence of (State (stv 1.0 1.0) (List alice thirsty) false). As a result it returns a result with second StateLink and AndLink at erroneous (stv 1.0 0.0). Is there a way to force the chainer to evaluate already grounded atoms as well?
(define target (And (State (List (Variable "person") hungry) true)
(State (List alice thirsty) true)))
(cog-bc rbs target #:vardecl variables)
; This returns (SetLink (ConceptNode "alice")), also ignoring the already grounded StateLink
(cog-execute! (Get variables target))
(define target (And (State (List (Variable "person") hungry) true)
(State (List alice thirsty) true)))
When you entered that, you just changed Alice's state. You didn't mean to, but atoms are globally-unique, and a StateLink can only have one state, so when the evaluator first sees that, it changes Alice's state, irrespective of it being wrapped up in the AndLink.
To add insult to injury, the pattern matcher completely ignores the second StateLink, because it has no variables in it, and thus is trivially present in the atomspace. I guess that the URE can still examine it, and do something with it's truth value, depending on which rule got triggered.
--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/5f6d23a9-a847-4fcb-85a2-a822cb1251f2%40googlegroups.com.
Hi Alex,The answer: yes, or rather no, and there's a bug in your example.The URE is built on top of the pattern matcher, and as mentioned earlier, the pattern matcher never alters truth values, and rarely looks at them, as it is only concerned with the presence/absence of patterns in the atomspace. As a URE user, you are welcome to write rules that examine truth values, and alter them in any way that you want. (I assume that one can also write URE rules that manipulate Values in general, but this may be cutting-edge, missing functions and utilities...) (see also /examples/atomspace/formulas.scm which presents the recommended way of handling these kinds of computations.)
The bug is here:(define target (And (State (List (Variable "person") hungry) true)
(State (List alice thirsty) true)))When you entered that, you just changed Alice's state. You didn't mean to, but atoms are globally-unique, and a StateLink can only have one state, so when the evaluator first sees that, it changes Alice's state, irrespective of it being wrapped up in the AndLink.To add insult to injury, the pattern matcher completely ignores the second StateLink, because it has no variables in it, and thus is trivially present in the atomspace. I guess that the URE can still examine it, and do something with it's truth value, depending on which rule got triggered.
(SetLink (AndLink (StateLink (stv 1.000000 1.000000) (ListLink (ConceptNode "alice") ; [6edb97fb269f42cf][1] (ConceptNode "hungry") ; [242c0228b7502b75][1] ) ; [bcc08bf365c085ef][1] (ConceptNode "true") ; [5ef6364983aee0cf][1] ) ; [84868fb1d3520298][1] (StateLink (stv 1.000000 1.000000) (ListLink (ConceptNode "alice") ; [6edb97fb269f42cf][1] (ConceptNode "thirty") ; [16526f8a1adbc29][1] ) ; [db02447762e2d55b][1] (ConceptNode "true") ; [5ef6364983aee0cf][1] ) ; [d3f761667ca45d1d][1] ) ; [d9a46b0c6194b7b8][1]) ; [e6b35cc2f9480d13][1]
Am Mittwoch, 26. Februar 2020 18:22:29 UTC schrieb linas:Hi Alex,The answer: yes, or rather no, and there's a bug in your example.The URE is built on top of the pattern matcher, and as mentioned earlier, the pattern matcher never alters truth values, and rarely looks at them, as it is only concerned with the presence/absence of patterns in the atomspace. As a URE user, you are welcome to write rules that examine truth values, and alter them in any way that you want. (I assume that one can also write URE rules that manipulate Values in general, but this may be cutting-edge, missing functions and utilities...) (see also /examples/atomspace/formulas.scm which presents the recommended way of handling these kinds of computations.)But my goal wasn't to alter the value, just to have it looked up. But you know that already ;)
If you ask me, we should remove the assumption of the default truth value upon atom creation.
Truth value definition should mean truth value changing, and not defining it should just create a pattern that one can feed to the system to query the truth values of a complex pattern. Unless there is another way to make a grounded complex query that I'm not aware of. (In which case please point me in the right direction ;)
The bug is here:(define target (And (State (List (Variable "person") hungry) true)
(State (List alice thirsty) true)))When you entered that, you just changed Alice's state. You didn't mean to, but atoms are globally-unique, and a StateLink can only have one state, so when the evaluator first sees that, it changes Alice's state, irrespective of it being wrapped up in the AndLink.To add insult to injury, the pattern matcher completely ignores the second StateLink, because it has no variables in it, and thus is trivially present in the atomspace. I guess that the URE can still examine it, and do something with it's truth value, depending on which rule got triggered.If I could get my wish of definable patterns to query complex truth states, I'd expect the matcher to go collect those truth values. As it is now, I'd expect it to throw an error and tell people that they're changing the KB state. Silently changing the KB state as well as silently assuming the truth value of the grounded atoms is default (regardless of what it's defined to be) seems like the worst choice.
On Wed, Feb 26, 2020 at 12:47 PM Alexander Gabriel <goo...@4d6.de> wrote:
Am Mittwoch, 26. Februar 2020 18:22:29 UTC schrieb linas:Hi Alex,The answer: yes, or rather no, and there's a bug in your example.The URE is built on top of the pattern matcher, and as mentioned earlier, the pattern matcher never alters truth values, and rarely looks at them, as it is only concerned with the presence/absence of patterns in the atomspace. As a URE user, you are welcome to write rules that examine truth values, and alter them in any way that you want. (I assume that one can also write URE rules that manipulate Values in general, but this may be cutting-edge, missing functions and utilities...) (see also /examples/atomspace/formulas.scm which presents the recommended way of handling these kinds of computations.)But my goal wasn't to alter the value, just to have it looked up. But you know that already ;)Well, but I didn't...If you ask me, we should remove the assumption of the default truth value upon atom creation.This is archaic; there's an idea that, if you ask for a truth value, you should get at least something, instead of throwing an error. Anyway, if I recall, the default is not actually stored; its merely returned if there isn't already some other truth value. So basically, if you get the default TV, that means there is no TV...
Truth value definition should mean truth value changing, and not defining it should just create a pattern that one can feed to the system to query the truth values of a complex pattern. Unless there is another way to make a grounded complex query that I'm not aware of. (In which case please point me in the right direction ;)Well, but of course there is! Just use the pattern matcher directly! (which you are already doing, in half of your examples). You are using the pattern matcher directly, whenever you say (cog-execute! (BindLink ...)) or (cog-execute! (GetLink ...)) That code path never goes through the URE, never looks at any rules.
If I could get my wish of definable patterns to query complex truth states, I'd expect the matcher to go collect those truth values. As it is now, I'd expect it to throw an error and tell people that they're changing the KB state. Silently changing the KB state as well as silently assuming the truth value of the grounded atoms is default (regardless of what it's defined to be) seems like the worst choice.OK, it sounds like you are frustrated, and for that I am sorry.
StateLink is by definition both stateful and "silent" and I don't really see any other way: some pop-up "Are you sure? Abort, retry, ignore."
The pattern matcher ignores truth values because that's just modular design. If you want to do something with truth values, that is an additional layer built on top of the core function. There are several reasons for this, besides modularity. One is the the lack of historical agreement about what the correct formulas are. Specifically, there was a battle: Pei Wang's NARS vs. Ben Goertzel's PLN. Which one has the correct rules? Maybe a third way? Maybe truth values should be truth-intervals? Maybe they should be histogrammed approximations to probability distributions learned from large datasets? Who knows? Untangling basic search from valuations is one way to allow freedom for exploring different theories of valuation.
This email is too long, but also be aware of probability: thanks to Kolmogorov, we know that "and", "or", "not" corresponds to set-intersection, set-union and set-complement, in a very precise way. So, the truth formulas for AndLink, OrLink: should they be ... ? boolean? set-intersection? maybe with Bayesian priors? Which? it's a mess.
--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/de9053fc-9b37-4471-9eb5-2da669beb6dc%40googlegroups.com.
BTW, the URE, really is just a way to form complex pattern matcher
queries, at least the backward chainer is exactly that.
I think this is another case for introducing Boolean Value, separated
from Simple Truth Value,
Hi Alex,
my recommendation is that you turn on the URE log and look at the
atomese code generated by the URE.
Hi Nil, I added the set_component method of the Logger class to the cython logger
interface, but after setting that to URE and the level to DEBUG the logger
still doesn't produce any output from the URE in python. My guess is that
the URE is using another instance of the logger and that adding a function
to the chainers to return that logger instance would be the easiest way
to get access to it from python.
My python project is quite complex and is interacting with a simulation
environment in gazebo over ros, so debugging the reasoning in scheme
doesn't really work as i can't reproduce the state of the atomspace reliably. Do you know of a way to get access to the URE logger from python that
already works?
Best,
--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/402a7064-035e-4cb6-85eb-484a058feac9%40googlegroups.com.
Hi Alex,
On 2/29/20 6:20 PM, Alexander Gabriel wrote:> Do you know of a way to
get access to the URE logger from python that
> already works?
Unfortunately I don't know a way, useless you call scheme from within
python of course. It looks like you'd need to create logger python
bindings and find a way to access the ure logger instance, as done in scheme
>
> Best,
>
> Alex
>
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
Oh, I see, so in order to use opencog's logger in Python ones needs to
first create one with
https://github.com/opencog/atomspace/blob/f7b99ec12d920f7a385cc477dd54abdc0a8768b1/opencog/cython/opencog/logger.pyx#L38-L47
Am I correct?
If you really need it to work in *all* cases, then something like this:(DefineLink(DefinedPredicate "is in state")(Lambda(VariableList (Variable "a") (Variable "b"))(Equal (Variable "a") (Get (State (Variable "b") (Variable "x"))))))which you would use like so:(cog-evaluate!(EvaluationLink (DefinedPredicate "is in state")(List (Concept "red light") (Concept "stop light"))))and that should work just fine. This might be overkill for what you are trying to do ... but it does work, and the intent is that, for complex situations, this is how you would do it.
someone = ConceptNode("bob")
has_crate = ConceptNode("has crate")
StateLink(someone, has_crate)
DefineLink( DefinedPredicateNode("is in state"), LambdaLink( VariableList(VariableNode("target"), VariableNode("state")), EqualLink(SetLink(ListLink(VariableNode("target"), VariableNode("state"))), GetLink(StateLink(VariableNode("anything"), VariableNode("state"))))))
query = EvaluationLink(DefinedPredicateNode("is in state"), ListLink(someone, ConceptNode("has crate")))
results = evaluate_atom(atomspace, query)
print(results)[2020-05-06 12:24:50:065] [ERROR] Either incorrect or not implemented yet. Cannot evaluate (SubsetLink (SetLink (ListLink (ConceptNode "bob" (stv 1.000000 1.000000)) ; [510da4194021b685][1] (ConceptNode "has crate") ; [7f11eb3c16f8beb0][1] ) ; [8983ace7aae6590b][-1] ) ; [e7b63e6f2f3e7452][-1] (GetLink (StateLink (VariableNode "anything") ; [7f082726ca4ddba3][1] (VariableNode "state") ; [38680c2d1603e9c8][1] ) ; [df8079f1c9baf09d][-1] ) ; [9e4a50ee0b3b95e2][-1]) ; [cf2ff93ac449180b][-1] (/home/rasberry/git/atomspace/opencog/atoms/execution/EvaluationLink.cc:100) Stack Trace: 2: basic_string.h:222 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_is_local() const 3: Logger.cc:594 opencog::Logger::Error::operator()(char const*, ...) 4: exceptions.cc:54 opencog::StandardException::parse_error_message(char const*, __va_list_tag*, bool) 5: exceptions.cc:82 opencog::StandardException::parse_error_message(char const*, char const*, __va_list_tag*, bool) 6: exceptions.cc:169 opencog::SyntaxException::SyntaxException(char const*, char const*, __va_list_tag*) 7: EvaluationLink.cc:100 _Z20throwSyntaxExceptionbPKcz() 8: basic_string.h:222 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_is_local() const 9: EvaluationLink.cc:299 bool_to_tv() 10: EvaluationLink.cc:999 opencog::EvaluationLink::do_evaluate(opencog::AtomSpace*, opencog::Handle const&, bool) 11: shared_ptr_base.h:729 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() 12: EvaluationLink.cc:868 opencog::EvaluationLink::do_eval_scratch(opencog::AtomSpace*, opencog::Handle const&, opencog::AtomSpace*, bool) 13: EvaluationLink.cc:999 opencog::EvaluationLink::do_evaluate(opencog::AtomSpace*, opencog::Handle const&, bool) 14: shared_ptr_base.h:758 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::_M_swap(std::__shared_count<(__gnu_cxx::_Lock_policy)2>&) 15: [0x4bc9ba] ??() ??:0 16: [0x4ba036] ??() ??:0 17: [0x4eb32f] ??() ??:0 18: [0x4e5592] ??() ??:0 19: [0x4e3e46] ??() ??:0 20: [0x493ade] ??() ??:0 21: libc-start.c:325 __libc_start_main() 22: [0x4934a9] ??() ??:0
Traceback (most recent call last): File "./example3.py", line 99, in <module> results = evaluate_atom(atomspace, query) File "opencog/bindlink.pyx", line 21, in opencog.bindlink.evaluate_atom (/home/rasberry/git/atomspace/build/opencog/cython/opencog/bindlink.cpp:1268)RuntimeError: Either incorrect or not implemented yet. Cannot evaluate (SubsetLink (SetLink (ListLink (ConceptNode "bob" (stv 1.000000 1.000000)) ; [510da4194021b685][1] (ConceptNode "has crate") ; [7f11eb3c16f8beb0][1] ) ; [8983ace7aae6590b][-1] ) ; [e7b63e6f2f3e7452][-1] (GetLink (StateLink (VariableNode "anything") ; [7f082726ca4ddba3][1] (VariableNode "state") ; [38680c2d1603e9c8][1] ) ; [df8079f1c9baf09d][-1] ) ; [9e4a50ee0b3b95e2][-1]) ; [cf2ff93ac449180b][-1] (/home/rasberry/git/atomspace/opencog/atoms/execution/EvaluationLink.cc:100)
--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/72094b32-a6e6-4820-9c5b-a97474f4d663%40googlegroups.com.
I think you are mis-using the StateLink. The intent of the StateLink is to force an atomic one-and-only-one "membership", ever. Thus the example (State (Concept "traffic light") (Concept "red")) means that "traffic light" can only have one color at a time, whereas lots of things can be red. It's not symmetric -- only the first atom is the thing that has the state. (Its also atomic, and can be accessed in multiple threads in a consistent, thread-safe manner)
You can count number of items in a link with ArityLinkscheme@(guile-user)> (use-modules (opencog) (opencog exec))
scheme@(guile-user)> (cog-execute! (Arity (Set (Concept "A") (Concept "B"))))
(NumberNode "2")(cog-evaluate! (GreaterThan (Arity (Set (Concept "A") (Concept "B"))) (Number 1)))(stv 1.000000 1.000000)
Am Mittwoch, 6. Mai 2020 18:42:33 UTC+1 schrieb linas:I think you are mis-using the StateLink. The intent of the StateLink is to force an atomic one-and-only-one "membership", ever. Thus the example (State (Concept "traffic light") (Concept "red")) means that "traffic light" can only have one color at a time, whereas lots of things can be red. It's not symmetric -- only the first atom is the thing that has the state. (Its also atomic, and can be accessed in multiple threads in a consistent, thread-safe manner)I'm aware. Let's say you have two traffic lights, each can only have one state/color at a time, but there are multiple traffic lights which can have the same color.(State (Concept "first traffic light") (Concept "red"))(State (Concept "second traffic light") (Concept "green"))You can count number of items in a link with ArityLinkscheme@(guile-user)> (use-modules (opencog) (opencog exec))
scheme@(guile-user)> (cog-execute! (Arity (Set (Concept "A") (Concept "B"))))
(NumberNode "2")(cog-evaluate! (GreaterThan (Arity (Set (Concept "A") (Concept "B"))) (Number 1)))(stv 1.000000 1.000000)Good to know, but that wasn't the goal. I want to check whether a specific traffic light is red.I can get all the traffic lights that are red with a getlink,
but they'll be wrapped in a setlink,
so I can't compare the set of many against my one traffic light node...unless I can check for something being an element of a setlink.
Best,Alex
--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/ed7a3675-7669-4cb1-95ca-d1382fd29a02%40googlegroups.com.
Hi Linas!
Am Mittwoch, 26. Februar 2020 22:24:45 UTC schrieb linas:If you really need it to work in *all* cases, then something like this:(DefineLink(DefinedPredicate "is in state")(Lambda(VariableList (Variable "a") (Variable "b"))(Equal (Variable "a") (Get (State (Variable "b") (Variable "x"))))))
--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/72094b32-a6e6-4820-9c5b-a97474f4d663%40googlegroups.com.
I just realized that the example below has a misleading, confusing bug in it. (besides the missing SetLink) The fix is ...On Wed, May 6, 2020 at 7:31 AM Alexander Gabriel <goo...@4d6.de> wrote:Hi Linas!
Am Mittwoch, 26. Februar 2020 22:24:45 UTC schrieb linas:If you really need it to work in *all* cases, then something like this:(DefineLink(DefinedPredicate "is in state")(Lambda(VariableList (Variable "a") (Variable "b"))(Equal (Variable "a") (Get (State (Variable "b") (Variable "x"))))))Arghhh, The get part of it should have been(Get (Variable "x") (State (Variable "b") (Variable "x")))so that the Lambda plugs in for the "b", and the Get does the search for the "x". Without this, the Get performs the searches for pairs "b" and "x" .. which was not the intent. And I am guessing that this is what screwed up everything, and lead to thoughts of SubsetLink...
Anyway, I'm in the process of fixingin Subset and some other things so be sure to pull a new atomspace .. say in 12 hours...