Closed linas closed 5 years ago
Also, I think that it will be easier to discuss the correct design, once most of the reduct engine is implemented and working. Attempting to design this before the rest of reduct is in place is almost guaranteed to create confusion. See issue #21 for the reduct design.
@linas, but we don't necessarily want to use IfThenElseLink
or CondLink
in this manner!
We want to port Combo to Atomese and IfThenElseLink
or CondLink
are very handy (if not absolutely necessary) for that.
For instance, here's how you'd express the max function (maybe it is the program we want to evolve)
Lambda
VariableList
TypedVariable
X
Type "NumberNode"
TypedVariable
Y
Type "NumberNode"
IfThenElse
GreaterThan X Y
X
Y
There's no need to have the pattern matcher involved. Though of course it could be, just not in the manner you've presented. For instance
Get
VariableList
TypedVariable
X
Type "NumberNode"
TypedVariable
Y
Type "NumberNode"
And
Present
X
Y
GreaterThan
Number 10
IfThenElse
GreaterThan
X
Y
X
Y
which will build the set of all pairs of numbers such that either the first or second element are greater than 10.
As you guessed CondLink
is just an IfThenElseLink
with an arbitrary number of (condition, result) pairs. I suppose we don't need an IfThenElseLink
if we have CondLink
but I wouldn't mind having both, just for usability, I'm neutral on that.
Get some subset of reduct working first. I'm concerned that this is over-engineering something simple, while at the same time ignoring the hard parts.
Sorry I don't get it.
What is being over-engineered?
How are you gonna express the max
program with SequentialOr
?
What good is getting some subset of reduct working first (we already have that BTW, on an old branch of @Yidnekachew, if it hasn't been deleted, and we already have a combo version of reduct anyway, I don't see what it is gonna enlighten that we don't already know)?
I'm totally for pushing reduct dev earlier than scheduled (it's coming pretty soon anyway), but again I just don't see what it is gonna tell us. Besides we need the operators before we can write reduction rules for them.
@linas, if you don't like adding IfThenElseLink
/CondLink
to the atomspace repo because you feel it's premature, it certainly can be added to the as-moses repo first, then once the proof-of-concept is convincing moved to the atomspace repo. I've asked @kasimebrahim to create an atomspace PR because it seems like a no brainer to me and the SPb folks have expressed interest in it. The other alternative is to add it to singnet/atomspace but I'd rather avoid that to not accumulate divergence.
Bind EvaluateableAtom IfSoResultAtom
Bind (Not (EvaluateableAtom)) ElseResultAtom
Is too verbose and what if EvaluateableAtom is random? It could be less verbose if we had letlink:
(LetLink (EvaluationLink ...) EvalResult
Bind
EvalResult
IfSoResultAtom
Bind
(Not (EvalResult))
ElseResultAtom
)
As i understand prolog lacks if-else operator, but some logical languages introduced it e.g. mercury. @linas I guess there is so many questions about if-else operator since we don't have a language tutorial, like https://docs.python.org/3/tutorial/ or mentioned mercury introduction. At least it should be stated somewhere "write in atomese like in prolog". Otherwise it is somewhat hard to come up with this bindlink trick.
OK, I thought about it some more; IfThenElseLink seems reasonable. How do you want CondLink to work?.
@noskill Yes, the LetLink is interesting. I think I kind-of want to avoid introducing it, for now.
@linas sorry for the late replay. This is what I have in mind w/CondLink, w/IfThenElseLink.
OK, I need a day or two tor review the pull req. If it does what the wiki page says then OK.
The pull-req does it support BOTH the flattened, and the non-flattened version, or only one? (I presume you want to support both...!?)
Edited for clarity
yeah both.
I'm think we're done with that, so I'm closing.
After spotting this work in progress: https://github.com/kasimebrahim/atomspace/commit/371efb59eb5b4a5bd5cbb7b6cc6e3c0d20a2e6d7 I would like to have a formal design discussed here. The CondLink has been discussed on and off for ten years now, and it always gets rejected because it is always problematic and has issues. I want to review the issues, here, and have this issue as a place to discuss alternative designs.
I'm not sure but I think the CondLink is being envisioned as a kind of if-the-else link:
so that when the above is executed, the
EvaluateableAtom
is evaluated first, and if it returns true, thenIfSoResultAtom
is returned as the execution result, else theElseResultAtom
is returend as the execution result.The problem that arises is that the
ElseResultAtom
is not definable, when there are variables. Consider this form:If the evaluatable clause is true, and we find some $X that matches, then there is no problem. However, if the evaluatable clause is false, then there is no such $X, and so it is impossible to say that X is a cat, because there is no such X. There is no way to get that X. The problem is that if-then-else is a kind of "law of the excluded middle", (see wikipedia) and the law of the excluded middle is well-known to cause these kinds of problems, which is why it is generally rejected in constraint-satisfaction systems, action-planning systems, route-finding systems, and theorem-proving systems. And since the atomspace plus URE is a bit like all of these, combined, we need to reject it as well.
The simplest replacement that I can think of is instead having a pair of BindLinks: instead of writing
write
and
The above is what you do when you want to have
IfSoResultAtom
andElseResultAtom
to be executable. But if you only want truth values, then its much simpler: useSequentialAndLink
There are two existing examples for this:and