aic-sri-international / aic-expresso

SRI International's AIC Symbolic Manipulation and Evaluation Library (for Java 1.8+)
BSD 3-Clause "New" or "Revised" License
8 stars 0 forks source link

Solve issue with comparing Rationals #44

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The clean up of syntax trees and expressions has made apparently a problem with 
comparing expected and actual Rational numbers in unit tests 
testConvexRewriterOnMessageBoundsBasicInnerUnconditional and 
testConvexRewriterOnMessageBoundsBasicInnerConditional.

These tests involve, among others, a Rational-valued symbol with value 6/7, 
which is output as 0.857142857. However, writing 6/7 as a decimal results in a 
periodic decimal expansion, so this Rational does not equal an expected value 
written down as 0.857142857. In fact, it will not equal *any* finite decimal 
description.

I am not quite sure how this used to work, but I left the old methods around 
for reproduction. It seems that it should not have worked though, and if it 
did, it was by some other covering problem.

It seems that one way of solving the problem is to introduce notation for 
specifying Rational-valued symbols by using fractions. Simply writing a 
fraction is not enough because it will be taken as a function application of / 
and still not compare as equal to a Rational symbol.

Original issue reported on code.google.com by rodrigob...@gmail.com on 23 Apr 2014 at 1:36