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

Question about duplication semantics #798

Closed
nasser opened this issue Nov 12, 2024 · 4 comments
Closed

Question about duplication semantics #798

nasser opened this issue Nov 12, 2024 · 4 comments

Comments

@nasser
Copy link

nasser commented Nov 12, 2024

What are the semantics of "duplicate" assertions? If I assert e.g. (is ball red) multiple times I get multiple results when I match on it, which indicates that the individual atoms are not "interned" or deduplicated in any way -- they are fully distinct. But when I remove-atom just once, they all disappear, which would indicate a kind of interning/deduplication.

(is ball red)
(is ball red)
(is ball red)
(is ball red)
(is ball red)

! (match &self (is ball $color) $color)

! (remove-atom &self (is ball red))

! (match &self (is ball $color) $color)
[red, red, red, red, red]
[()]
[]

Can you clarify what is happening?

@vsbogd
Copy link
Collaborator

vsbogd commented Nov 14, 2024

Currently MeTTa doesn't specify this behavior, and it is implementation specific. Other implementation of the space can have different behaviour. As far as I know nobody relies on the current behavior of the default in-memory atomspace in hyperon-experimental. I agree it doesn't look very uniform, but on the other hand it allows doing manual deduplication easily.

I raised #799 to change it to more uniform. If @Necr0x0Der agree we can change this behavior. But I would like to emphasize one more time - you cannot rely on this.

@nasser
Copy link
Author

nasser commented Nov 14, 2024

understood -- thank you!

@Necr0x0Der
Copy link
Collaborator

Allowing duplicated atoms was supposed as a feature, because there were some use cases for PLN, when one needs to count the number of observed atoms to infer truth values. However, since MeTTa started to be used in more ways, it seems that absence of deduplication became more frequently a nuisance rather than a feature (and when one wants to count the same atoms, it can be done manually). OTOH, duplication can also be useful for probabilistic programming to control probabilities of sampling... Thus, I agree with @vsbogd that we still don't have a firm opinion and specification of this behavior, and it may change. In any case, it is indeed space-specific. I also agree that with duplication, it would be more convenient for remove-atom to remove only one atom.

@vsbogd
Copy link
Collaborator

vsbogd commented Nov 15, 2024

Closing it, @nasser please feel free to reopen if you have further questions on this.

@vsbogd vsbogd closed this as completed Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants