hakaru-dev / hakaru

A probabilistic programming language
BSD 3-Clause "New" or "Revised" License
309 stars 30 forks source link

Maple tries to include "limit" in `simplify` solution #73

Closed GenevaS closed 7 years ago

GenevaS commented 7 years ago

I have a program that previously simplified to the same program with different variable names. Maple now returns an error after a recent update stating that "limit\n" is not in scope. Is this a bug?

The program and error are:

x <~ gamma(6.0, 1)
poisson(x)
"Name not in scope: limit\n perhaps it is a typo?"
after sending to Maple:
use Hakaru, NewSLO in timelimit(90, RoundTrip(Bind(GammaD((6/1), 1), x, PoissonD(x)), HMeasure(HInt(Bound(`>=`,0))))) end use;
yuriy0 commented 7 years ago

I get a different result as of becf0433. In Maple syntax, the result is:

Weight(1/7680, Bind(Counting(0, infinity), kk下, Weight((kk下^5+15*kk下^4+85*kk下^3+225*kk下^2+274*kk下+120)*2^(-kk下), Ret(kk下))))

in Hakaru syntax, it is:

weight(1/7680,
       kk七 <~ counting
       weight(real2prob((int2real(((kk七 ^ 5)
                                    + 
                                   ((kk七 ^ 4) * 15)
                                    + 
                                   ((kk七 ^ 3) * 85)
                                    + 
                                   ((kk七 ^ 2) * 225)
                                    + 
                                   (kk七 * 274)
                                    + 
                                   120))
                          * 
                         prob2real((2 ** (int2real(kk七) * (-1)))))),
              return int2nat(kk七)))

If you had a program whose simplification output contained a limit, it would certainly cause this error; but I can't reproduce it.

I am aware of what seems to be a related issue - with PARTITION as an unrecognized name, in e.g.:

use Hakaru, NewSLO, Partition in timelimit(90, Simplify(lam(x0, HReal(), case(And((0/1) < x0, x0 < (1/1)), Branches(Branch(PDatum(true, PInl(PDone)), Ret(Datum(unit, Inl(Done)))), Branch(PDatum(false, PInr(PInl(PDone))), Msum())))), HFunction(HReal(), HMeasure(HData(DatumStruct(unit,[])))))) end use;

Maple handles this, but it is not parsed back to Haskell, presumably because Partition is not expected in the output.

JacquesCarette commented 7 years ago

So it looks like this particular issue can be closed?

yuriy0 commented 7 years ago

Until the error in question can be reproduced, yes.