ExtensityAI / symbolicai

Compositional Differentiable Programming Library
BSD 3-Clause "New" or "Revised" License
978 stars 56 forks source link

Causal Reasoning Expressions Not working #71

Closed abd-als closed 1 month ago

abd-als commented 1 month ago

Im trying to use the expressions interpret and expression but it doesnt seem to work.

res = ai.Symbol('The horn only sounds on Sundays.') & ai.Symbol('I hear the horn.')
res
;class symai.symbol.Symbol at 0x11a6d7a10>(value=The horn only sounds on Sundays.I hear the horn.)

The actual output should be : <class 'symai.expressions.Symbol'>(value=It is Sunday.)

What I get is "(value=The horn only sounds on Sundays.I hear the horn.)" which just adds them together the Reasoning part is not working.

futurisold commented 1 month ago

Hey! Sorry for the late reply. There was a subtle bug, which we fixed in the meantime. Please pull latest main and use as follows:

from symai import Symbol

s1 = Symbol('The horn only sounds on Sundays.', only_nesy=True)
s2 = Symbol('I hear the horn.')

print(s1 & s2) # or |

The first symbol (in the above case that's s1) must have the only_nesy flag set to True for the logical operators. Without going into detail for why we did this, the tl'dr is that we didn't find a better way in python to do meta-overloading. Without this flag, the logical operators default to string concatenation. For us, having syntactic sugar for concatenation is important, such as being able to use operators like 'A' & 'B' & 'C' to produce 'ABC' or 'A' | 'B' | 'C' to result in 'A B C '.

Please confirm it's working on your end as well.

futurisold commented 1 month ago

Due to innactivity.

abd-als commented 1 month ago

Screenshot 2024-09-16 at 8 40 11 PM (2)

hello, It still gives out the same output

futurisold commented 1 month ago

I'm not sure what's the issue. It could be that the jupyter state messes something up.

On my machine on latest main: image