Re: [eclipse-clp-users] PyCLP inconsistency in treating 0 (zero)

From: Thorsten Winterer <thorsten_winterer_at_web.de>
Date: Fri, 13 Dec 2013 11:56:23 +0100
Hi,

as I was fighting the very same problem this morning, I would like to
point to another related problem:
the Python booleans True and False are not transformed into ECLiPSe
booleans true and false, but instead treated as integers, resulting in 1
and _ values, respectively.

Unfortunately, these two issues are showstoppers for me, so if anyone
has a suggestion how to fix PyCLP's Term class, I'd be very grateful...

Thorsten


Am 13.12.2013 11:45, schrieb Federico Ferri:
> I found a problem in how pyclp builds terms for eclipse.
>
> Let's say I want to post the goal X is 2+3:
>
>   import pyclp
>   pyclp.init()
>   X=pyclp.Var()
>   goal=pyclp.Compound('is', X, pyclp.Compound('+', 2, 3))
>   print('goal: %s' % goal)
>   goal.post_goal()
>   ret,arg=pyclp.resume()
>   print('X = %s' % X.value() if ret else 'goal failed')
>
> gives the expected output:
>
> goal: is(_,+(2,3))
> X = 5
>
>
> Now if I want to post the goal X is 0+3, I use the very same program
> as above, just replacing 2 with 0, and here's the output:
>
> goal: is(_,+(_,3))
> X = None
>
> Apparently, 0 becomes a variable, which does not look correct.
>
> I thought that this was my mistake, and I should have been explicitly
> creating numbers with a pyclp constructor, but building the goal as:
>
>   goal=pyclp.Compound('is', X, pyclp.Compound('+', pyclp.Term(0),
> pyclp.Term(3)))
>
> or as:
>
>   goal=pyclp.Compound('is', X, pyclp.Compound('+', pyclp.Atom('0'),
> pyclp.Atom('3')))
>
> yields to the same output:
>
> goal: is(_,+(_,3))
> X = None
>
>
> Additionally, building the goal as:
>
>   goal=pyclp.Compound('is', X, pyclp.Compound('+', '0', '3'))
>
> yields to a different stringification:
>
> goal: is(_,+("0","3"))
> X = None
>
> I'm not sure if "0" and "3" are truly strings, because in an
> interactive eclipse interpreter, I get those results instead:
>
> [eclipse 1]: X is 0 + 3.
> X = 3
> Yes (0.00s cpu)
>
> [eclipse 2]: X is '0' + '3'.
> calling an undefined procedure '0'(_209) in module eclipse
> Abort
>
> [eclipse 3]: X is "0" + "3".
> number expected in +("0", "3", _281)
> Abort
>
>
>
> Some interesting facts from the python console:
>
> >>> str(pyclp.Atom('0'))
> '0'
>
> >>> str(pyclp.PList([1,0,1,0]))
> '[1,_,1,_]'
>
> >>> str(pyclp.PList(list(pyclp.Atom(str(x)) for x in [1,0,1,0])))
> '[1,0,1,0]'
>
>
> I'm a bit puzzled, I think I will file a bug report to PyCLP
> Has anyone encountered this before?
>
>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT 
> organizations don't have a clear picture of how application performance 
> affects their revenue. With AppDynamics, you get 100% visibility into your 
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>
>
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
Received on Fri Dec 13 2013 - 10:56:34 CET

This archive was generated by hypermail 2.2.0 : Fri Dec 13 2013 - 18:13:13 CET