Skip to content
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

superpose behaves differntly too multiple definitions #859

Open
rTreutlein opened this issue Feb 26, 2025 · 3 comments
Open

superpose behaves differntly too multiple definitions #859

rTreutlein opened this issue Feb 26, 2025 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@rTreutlein
Copy link

Describe the bug
my understanding was that the below definitions for f1 and f2 should be identical but as we can see in the output they are not.

To Reproduce

(= (f1 $a) (unify $a 1 a Empty))
(= (f1 $a) (unify $a 2 b Empty))

!(let $inp $inp (let $res (f1 $inp) ($inp $res)))
;[(2 b), (1 a)]

(= (f2 $a) (superpose ((unify $a 1 a Empty)(unify $a 2 b Empty))))

!(let $inp $inp (let $res (f2 $inp) ($inp $res)))
;[($inp a), ($inp b)]

Expected behavior
f2 should output the same as f1

Actual behavior
f2 doesn't subsitute the result of the unification in the higher context.

@vsbogd
Copy link
Collaborator

vsbogd commented Feb 28, 2025

Well it is old restriction of the grounded atoms API. See for example option (2) inside #530 (comment) The problem is that result cannot be returned via argument of the grounded operation. The difference between f1 and f2 is that f2 calls grounded superpose and this call breaks the chain of variable assignments.

It is not fundamental issue and it can be fixed as wrote in #530 (comment) After migration to the minimal MeTTa I believe it should not be complex but it changes the grounded atom API so it is a major change.

@vsbogd vsbogd self-assigned this Feb 28, 2025
@vsbogd vsbogd added the enhancement New feature or request label Feb 28, 2025
@rTreutlein
Copy link
Author

rTreutlein commented Feb 28, 2025

@vsbogd Well either way both functions should behave the same way. Personally i would change the way superpose works even it is major change (As we don't have a final version of metta major changes are to be expected). If there is a big argument against that i also woulnd't mind if the way f1 works get changed to be the same as superpose. It would be a bit annoying to write functions in such a way that they always return inputs and then do seperate unification of the input with the updated input returned by the function but it would work. But it's not nearly as clean as allowing superpose to updates it's arguments.

@vsbogd
Copy link
Collaborator

vsbogd commented Feb 28, 2025

@rTreutlein I agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants