# [suby-talk] Symbolic Logic

Tue Oct 4 15:38:41 EDT 2005

```On Sun, 25 Sep 2005, TRANS wrote:

> Only that !, &&, || are not definable methods, but ~, &, | and ^ are.

Ah, right. Something we should correct in Suby? It does not help for
Nano/Mega, although I hope you will have a version of Nana and Mega that
will make use of Suby's features! Well, some day :-)

>>>> This could possibly be extended to polynomial things, so "5 *
>>>> :x * :y" would work too.
>>>
>>> Interesting. Hadn't though of that. Symbol could be Symbolic Formula?
>>> Well, we do call it Symbolic Logic after all :-)
>>
>> Yup. So, another addition to Mega? I wouldn't mind trying to implement all
>> this you know.
>
> Sure thing! That'd be great! In fact w/ your Prolog background I
> imagine this is your cup of tea.

Er... It does not have that much to do with Prolog. But it is my cup of
tea.

Actually I'll probably need this for the precision stuff. I have part of
the implementation. For example I could do this:

1.to(5) # => a value with 3.0 as best guess ((1.0 + 5.0) / 2.0),
#    1.0 as minimum value and 5.0 as maximum value.
#    #to_s gives: 3.0 (1.0..5.0)
3.pm(2) # => same thing
3.pm(5) * 3.pm(5) # => 9.0 (-16.0..64.0)

However what I have is not entirely accurate. For example

a = 3.pm(5) # => 3.0 (-2.0..8.0)
a * a # => 9.0 (-16.0..64.0)

Note that a * a, or a squared, can never be negative. Yet my library says
so because it sees both a's as separate values. They are not though, and
it is not that easy to do this right in general. Hence I need to track
the history of operations as a symbolic expression. Which is where the
symbolic stuff comes in.

Peter
```