trueagi-io / hyperon-experimental

MeTTa programming language implementation
https://metta-lang.dev
MIT License
133 stars 44 forks source link

Python grounded 1 is equal to grounded True #601

Open vsbogd opened 6 months ago

vsbogd commented 6 months ago

Following example returns [ok] while it is expected to return [(foo True)]:

(= (foo 1) ok)
!(foo True)

The reason is that in Python 1 == True:

$ python -c 'print(1 == True)'
True
Necr0x0Der commented 6 months ago

When/if we move to having grounded atoms in Rust with automatic conversion to Rust, we may want to revisit this issue.

vsbogd commented 6 months ago

When/if we move to having grounded atoms in Rust with automatic conversion to Rust, we may want to revisit this issue.

I don't think the result will be different. If two atoms are Python grounded atoms and checked for equality then Python equality function is called.

I think we can override Python equality for grounded atoms to check type equality before checking value equality. Or specifically check this case if two values are considered equal.

Necr0x0Der commented 6 months ago

My plan was to try removing Python grounded functions, but yes, I'm not sure if we can avoid removing equality. If not, it poses an interesting question if we can call Rust equality on Rust objects and Python equality on Python objects. It seems not that straightforward as I hoped.