Suggestions on how to infer types for prolog/clp variables?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Suggestions on how to infer types for prolog/clp variables?

fybertas
Hello, friends:
Currently I am doing a transformation from prolog into constraint logic programming(clpfd).
One problem I am facing now is how to differentiate between variables: for instance, some variables will bound to a integer while others might bound to characters; If I insert domain definition (e.g. "Var in inf..sup "), there will be an type error if the variable Var is not meant to bound to a variable.
One idea I came up with is to infer the types of such variable through the context: after I read in a line, if the variable detected is involved in arithmatic operation(e.g. "Var1 is Var2 - 1" or "Var1 > Var2"), we can make the assumption that both Var1 and Var2 are bound to integers(we ignore the complications of float numbers at this moment) and safely insert the domain definition.
I am still not sure about how to implement this (libraries?) and whether this is a legit approach. Any ideas or concerns will be highly appreciated.

Thanks,
Yu Fu
School of Information Sciences and Technology
Pennsylvania State University, USA
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Suggestions on how to infer types for prolog/clp variables?

Carlo Capelli-2
Hello Yu Fu

I'm sorry I can't help, but I'm curious to know something more about your
attempt.
The usual way it's from more declarative languages to 'lower level'
implementation languages.
If you are going to reverse this well known schema, maybe your first
concern should be about how to handle control flow.
At first glance, seems impractical.

Carlo



2014-09-05 23:16 GMT+02:00 fybertas <[hidden email]>:

> Hello, friends:
> Currently I am doing a transformation from prolog into constraint logic
> programming(clpfd).
> One problem I am facing now is how to differentiate between variables: for
> instance, some variables will bound to a integer while others might bound
> to
> characters; If I insert domain definition (e.g. "Var in inf..sup "), there
> will be an type error if the variable Var is not meant to bound to a
> variable.
> One idea I came up with is to infer the types of such variable through the
> context: after I read in a line, if the variable detected is involved in
> arithmatic operation(e.g. "Var1 is Var2 - 1" or "Var1 > Var2"), we can make
> the assumption that both Var1 and Var2 are bound to integers(we ignore the
> complications of float numbers at this moment) and safely insert the domain
> definition.
> I am still not sure about how to implement this (libraries?) and whether
> this is a legit approach. Any ideas or concerns will be highly appreciated.
>
> Thanks,
> Yu Fu
> School of Information Sciences and Technology
> Pennsylvania State University, USA
>
>
>
> --
> View this message in context:
> http://swi-prolog.996271.n3.nabble.com/Suggestions-on-how-to-infer-types-for-prolog-clp-variables-tp14995.html
> Sent from the SWI Prolog mailing list archive at Nabble.com.
> _______________________________________________
> SWI-Prolog mailing list
> [hidden email]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
-------------- next part --------------
HTML attachment scrubbed and removed
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Loading...