-
Notifications
You must be signed in to change notification settings - Fork 233
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
Inconsistent unification in atomese #2650
Comments
As i understand, unification is currently implemented in URE, we may expose it as UnificationLink which should be a Evaluateable link returning true on successful unification. |
Also it shouldn't be difficult to support matching of value types, at least ListValue may be described by the same pattern as ListLink. |
One quick remark: To indent scheme properly, indent exactly the same way you would in python. This is not an accident: when python was being invented, it took inspiration from scheme for many design ideas, e.g. lists, comprehensions, etc. but also for indentation! It took the scheme indentation rules and made them mandatory, instead of optional. So - to indent scheme properly, just pretend it was python and it was "significant whitespace". |
The inf-loop thing is a bug. I'll try to fix it now. I don't understand the comment about unification. Could you elaborate? |
In the meanwhile, you can avoid the inf-loop by tightening up the search. Try this
This speeds things up by avoiding potentially goofy groundings for the variables. Due to the bug, one of the goofy groundings included plugging in everything for variable Y and N, including the Member, the And, the Query and the Equal itself, and I think the plugging the Equal back into itself was the inf loop. Some craziness similar to |
First draft for fixing opencog#2650
So, the first part of this bug report is fixed in #2652 There's also a performance side-effect. Instead of writing
it would be more efficient to write
The reason for this is that
and the second component is
Each component is grounded separately, and then these are pair-wise compared with the The other way to avoid the quadratic run-time is to use "deep types". That looks like this:
The correct way to read this is that variable Y can be anything, as long as that anything has the shape of |
The query with the PredicateForumla is also a bug. The short answer: PredicateFormulas are so new, they've never been used with the pattern engine before, and there seem to be three or 4 different bugs, each of which is causing that example to fail. |
about unification: ure unifier is described here https://github.com/opencog/ure/tree/master/opencog/unify. I think it's functionality should be exposed in atomese as an evaluateable link, not only through c++. @ngeiswei what do you think? Well, actually why EqualLink doesn't work like that? Evaluation link has with the same arguments: (cog-execute! (Query
(And
(TypedVariable (Variable "Y") (Type 'List))
(TypedVariable (Variable "N") (Type 'Concept))
(Member
(Evaluation (Predicate "has_name") (Variable "Y"))
(Concept "node2"))
(Equal (Variable "Y")
(List (Variable "N") (Concept "name1"))))
(Variable "Y"))) and here (cog-evaluate! (EqualLink
(ListLink (ConceptNode "node1") (ConceptNode "name1"))
(ListLink (VariableNode "N") (ConceptNode "name1")))) As for value matching i think about something like that:
|
By the way, is there a way to perform recursive matching, to let say calculate a height of an atomese tree? |
Work like what? Please explain. I showed you SignatureLink, it seems that this is what you want.
I have no clue at all what you expect to happen here. You'll have to explain.
This already works, and is simpler:
|
This is the actual fix for (the second part of) bug opencog#2650
This is part two of the actual fix for (the second part of) bug opencog#2650
@noskill Oh, maybe I do understand what you mean by "unification": it is described in this enhancement request: issue #554 The example I just added today:
Currently, the pattern matcher runs this and evaluates the EqualLink last. It could have done this at pattern compile-time instead, and just plugged in for |
@noskill said:
You're absolutely right. Actually, I think the following branch (a prototype to support meta-rule in the backward chainer [EDIT: that I indent to review and merge as time permits]) contains such a link (or bindings) https://github.com/opencog/ure/tree/rTreutlein-MetaRuleSupport |
@linas, I'm not sure I understand what is being asked for, but in @noskill's words
I think (UnificationLink
(Inheritance (Concept "A") (Variable "$Y"))
(Inheritance (Variable "$X") (Concept "B")) would evaluate to true. Though in the context of having such virtual link in a query, thus having variables eventually replaced by grounded atoms, I guess it would be equivalent to (EqualLink
(Inheritance (Concept "A") (Variable "$Y"))
(Inheritance (Variable "$X") (Concept "B")) What the URE unifier can offer though is statically rule out unsatisfyable equalities. |
OK, so .. it is certainly plausible to have a |
Not groundings but substitutions, so for instance if we try to unify
with
the set of possible substitutions (here only one) would be
|
OK, so, a new
where typically, n=2 for the usual case, and the variables, if not specified, are implicitly extracted. I guess all the usual stuff about typed-variables would apply (so in your example, if there was a One could then say Does the above describe the idea? Did I miss something? Is there something more? All of your examples show something unusual: the unification never-ever depends on the other contents of the AtomSpace. That is, the unification can be done once and for-all statically, and it will never change. Is that correct? If so, then we have two choices: perform the unification immediately, when the atom is created, or defer unification until later, when it's asked for, and then cache the result, in case it is ever asked for again. I'm wondering if we really need a new |
FWIW, what you are calling "unification" is what I am trying do do more generally, with the idea of "connectors" and "sheaves". In your examples, variables can be aligned with other atoms, and as long as they line up, the connection can be made. The result of a single connection is a "linkage" - what you are calling a "substitution". For the general link-grammar case, you don't have just "variables" and "things that the variables match up to", but rather two end-points, and either the end-points can connect, or they cannot. In your case, a variable can connect to anything, (if the variable has no type constraints) I'm trying to change the vocabulary from "variables" and "things that plug into variables" to instead be "connectors" and "rules for connecting connectors". The reason for changing the vocabulary is that the language "variables" and "things that plug into variables" has an implicit directionality from->to and I want to have non-directional connections. The reason for this is partly due to the influence of link-grammar (and more generally, categorial grammars) where the vocabulary of "variables" and "things that plug into variables" is confusing and misleading, whereas "connectors that can plug together" is more accurate. This minor change in vocabulary solves a lot of problems, and avoids a lot of confusion ... A lot of what I see written up in academic papers is rife with this confusion, and thus results in bizarre and unfounded claims. However, de-tangling this concept of "things that can be plugged together" is hard, because .. well, I used to make that mistake too, and the entire pattern engine is founded on that confusion. Undoing that confusion will be a large undertaking. |
Exactly.
No, it perfectly describes what the unifier does.
Yes. It is purely functional, and as such can easily be memoized (though it's not implemented yet).
For regular queries EqualLink should be enough, but for more sophisticated ones, such as queries sticking together queries to produce larger queries, then I think a UnificationLink is necessary. With that I think the URE could actually be implemented in Atomese, it seems. |
Very interesting! |
To clarify several more things:
The last bullet is the important one... Just to provide contrast: once could also ask "what good is For PLN, we have |
Agreed.
I don't precisely see either but I vaguely see piping its output to some put link to create new inference trees, etc.
To write specialized chainers. |
Yes. I'm also vaguely and slowly working through the connectors idea, but for something so "obvious", it's also surprisingly difficult. @noskill its kind-of on you now, to push on this if you want this to work in some certain way, or to be used for something. |
I tried to use EqualLink for unification of a variable with a pattern:
For some reason this is ok:
But this one causes "C++-EXCEPTION' with args `("cog-execute!" "Infinite Loop detected! Recursed 6 times!"
Another inconsistency:
ok
not ok
I think it would be useful to expose unification of subgraphs as a link:
Here first list link may be unified with the second.
The text was updated successfully, but these errors were encountered: