-
Notifications
You must be signed in to change notification settings - Fork 236
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
Eliminate MapLink #2203
Comments
@linas, how to make |
GetLink already "doesn't search the whole atomspace". it only seems to, conceptually. In practice, it searches only a tiny portion of it. Some examples (copied from #2202)
which searches ONLY the members of "my set". Even better:
which is a processing pipeline: accepts "my-set" as input, and places results into "the next stage set". BTW, I use AnchorNode for this (i.e. Processing pipelines could be even further improved, e.g. #1750 and/or #1507 |
Ah, as long as it is efficient it's OK, which I'm not entirely sure of, but maybe it's another issue. |
It is question for both this issue and issue #1502. For example query "get all baskets which contain only red balls" can be written as: (cog-execute! (Get
(Variable "basket")
(And
(Inheritance (Variable "basket") (Concept "basket"))
(Equal
(Set)
(Get (Variable "ball") (And
(Member (Variable "ball") (Variable "basket"))
(Absent (Evaluation (Predicate "is-red") (Variable "ball")) )
))
)
)
)) But this query relies on inner |
There's a way to do that -- two ways, actually. One way is to realize that you are doing implicitly chaining, and acknowledge that, and just be explicit about it. The other way is to include the anchor for member as part of the search pattern. I'd like to provide a longer detailed answer to this, to make this clear, but can't right now, distracted with other things :-/ |
If I understand second way properly you are proposing adding I don't understand the first way, what do you mean by explicit chaining? |
I wonder if that issue isn't fundamentally related to the notion of https://en.wikipedia.org/wiki/Continuation (which is a bit above my head frankly). |
@vsbogd if this has actual, direct impact on your work, I can take some time provide a detailed answer; right now, I have other urgent bugs which seem more important that I want to get to. I mean, you have good questions that deserve detailed examples, but I'm overwhelmed at the moment. @ngeiswei that particular wikipedia article is a classic example of "you won't understand it unless you already know it", it's more or less a terrible article. There's actually a very simple way to explain continuations: They're just like C++ objects. Or rather, C++ objects with just one anonymous method. When you call a continuation, it "magically" remembers internal state the same way that a C++ instance "remembers" internal state. Here is the (slightly buggy) C++ version of the example in that article:
The only "bug" in the above is that function pointers and method pointers in C++ can't be mixed the way I mixed them, so you would need to glom this up with extra syntax to make it actually work. But that is all that the first example is doing. Continuations are just objects with a single anonymous method. There's a bit more; its a Zen-master story:
Once you get it, continuations are actually simpler, easier, nicer and more powerful than objects, but for starters, just think of them as anonymous objects with a single anonymous method (because that is what they are). |
Well, I messed that up. Its actually "closures are a poor-man's object". Continuations are more like a go-to statement into an object. Or actually, even more like a come-from statement in an object: https://en.wikipedia.org/wiki/COMEFROM Whatever. you do certainly need to grok closures in scheme (its not hard); continuations are .. less structured and uglier as a result. |
Thanks guys, I understand what is a continuation now, in principle at least (which is different from having practical experience with it). |
@linas, there is no urgency, so please answer when you have time. |
@vsbogd you asked:
Yes, this is a problem. It's roughly equal to having to clean up SetLinks. Both can be done by performing searches in child atomspaces, and then popping when done The push-pop solution has the advantage of being thread-safe; you can have two different searches running at the same time, using the same Anchor, without each one polluting the Anchor with results from the other one. Without the push-pop, the use of AnchorNode is NOT thread-safe; this line of reasoning lead to #1750 - a publish/subscribe system, so that the results of the first search are seen only by those who are subscribed to get them. |
@vsbogd you asked:
This is a very interesting and challenging question. It is making me contemplate implementing a
Chaining is the wrong word. I'm not sure what the right word is. I meant "just basic expansion". Since this issue is wayyy off topic, already, it won't hurt to post a solution. It's done in two steps: first, find all baskets containing balls that are not red. Second, find baskets which aren't one of those. This is a sequential running of two term re-writing steps. The first search pollutes the atomspace with BTW, one way to think of this is that the Here's the sequence-of-two-rewrite-rules solution:
|
Once there's an itch, I want to scratch it. As of pull req #2288 there is now an @vsbogd you are invited to cook up more complex examples. Your ball-in-basket example also had the general flavor of a set-intersection type problem, and I imagine that there are other similar queries that are currently awkward, hard to express. We should look at them. |
Hi @linas, BTW, I found another way to re-write this query via (cog-execute!
(Get (Variable "basket")
(And
(Inheritance (Variable "basket") (Concept "basket"))
(NotLink (SatisfactionLink (Variable "ball")
(And
(Member (Variable "ball") (Variable "basket"))
(Absent (Evaluation (Predicate "is red") (Variable "ball")) )
))
)
)
)) |
I enshrined the not..exists...absent variant in Reading it feels like reading some textbook in set theory, where you have to mentally parse these long expressions "not and exists or equals and not always greater..." hard for humans to do. The goal with all of these is that, in the long run, some other algo (PLN, moses, maybe even VQA?) are generating these queries and launching them ... so we need to make it easy for these other algos to run these things. |
Closing. Won't-fix. They're actually useful. I renamed |
MapLink does not seem to serve any useful purpose. This issue proposes eliminating it, and/or debating reaoson why it should stay (and be improved/changed) Some background comments about it.:
The text was updated successfully, but these errors were encountered: