-
Notifications
You must be signed in to change notification settings - Fork 18
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
How to emulate lambda calculus? #39
Comments
This is solved by sealing the arguments in respective scopes, which would split $y in the final reduction step (disallowing non-local unification, but also enabling the individual reductions). |
There may be a workaround with a drawname grounded function that gives you a fresh variable to use in the beta reduction. |
Right! So I suppose you mean something like
That's a great suggestion, although I feel we may still want to consider adding a built-in scope or sealing (if there's a difference). |
Oh, actually that doesn't work either in my test case :-(, maybe you meant something else... |
Actually I think it does work! But the code should be
i.e. no need to alpha-convert |
@Adam-Vandervorst, would you mind showing how the solution using |
Basically |
The English is the desired requirement for seal, yes! |
I see... You've automatically alpha-converted
rewrites into
which rewrites into (note how the outer
which is OK because
Then MeTTa needs to unify But I wonder how is |
@ngeiswei , thanks for raising it again. We already had a workaround for this in old Rust interpreter thus your code will work correctly with minimal MeTTa disabled. In minimal MeTTa I like your suggestion:
It should work exactly as previous |
In hyperon-experimental all variables inside But we could use sealing inside
|
It indeed works with the old MeTTa. Ah, you've already answered that above. |
@ngeiswei it should work in a following form on the branch from trueagi-io/hyperon-experimental#609:
|
We can implement it as |
I don't know either. Somewhat perhaps related, after reading @leithaus Transparent MeTTa proposals, I wonder if we wouldn't want to replace variables by a quotation construct If we don't want to depart from |
Wow, I confirm that it solves the problem on my end. |
Implementing lambda requires variables with restricted scope, see trueagi-io#39
SICP and combinator logic examples also suffer from this. Possible fix which uses non-merged seal is in my private branch https://github.com/vsbogd/metta-examples/tree/minimal-seal-patch |
What is your problem?
I cannot emulate lambda calculus, I would say due to a lack of support for scopes in MeTTa.
How to reproduce your problem?
Run the following code
What do you get?
It outputs
[]
.What would you want to get instead?
It should never halt, as per the mockingbird infinite loop
(M M)
.Why do you think that is?
The problem comes the fact that
reduces to
which reduces to
which finally reduces to
which fails because
$y
does not unify with(λ $y ($y $y))
.You can see that this is caused by the absence of alpha-conversion, because
λ
is not treated as a scope.What other questions do you have?
Do we need scopes in MeTTa?
If the answer is no, then how to emulate lambda calculus in MeTTa?
The text was updated successfully, but these errors were encountered: