Re: Ideas on how to transform a prolog program into a clp program
Jan Wielemaker <[email protected]> Tue, 8 Apr 2014 09:20:09 +0200
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 08-04-14 02:38, fybertas wrote: > I've been trying to transform a prolog program into a clp(constraint > logic program): therefore, I need to add finite domain constraints to > variables in the program; I also need to change the operators in the > program to their equivalence in clp (for instance, change "<" into > "#<"). Most likely it is not that simple. For example, clp(fd) doesn't like cuts too much ... If the program works, it is also not clear what you gain. It might turn single moded predicates into multi moded ones. If that is what you are after, you could be on the right track. > But I am kind of stuck as to how to implement this using prolog, here are > two possible ways IMO: > (1) process the prolog file by term input/output, identify the terms and > clauses(which is not very explicit), then perform the above two > transformation. That is done using term_expansion/2 (or maybe just goal_expansion/2) in this case. E.g., goal_expansion(A<B, A#<B). > (2) read in the file using "consult", then process the clauses in the > memory, use assert and retract to manipulate clauses. Yes, but the output will look ugly as you loose all variable names and all comments. > (3) Or maybe there are some library that can help me with this? See http://www.swi-prolog.org/pack/list?p=refactor. It seems the pack is not upgraded regularly. You can find the github repo by clicking on the author's link (Edison Mera). There you find recent activity. Hope this helps Cheers --- Jan > > Could someone shed some light on this? I have tried to find tutorials on > advanced Prolog programming but couldn't find much. > > > > -- > View this message in context: http://swi-prolog.996271.n3.nabble.com/Ideas-on-how-to-transform-a-prolog-program-into-a-clp-program-tp14746.html > Sent from the SWI Prolog mailing list archive at Nabble.com. > _______________________________________________ > SWI-Prolog mailing list > [email protected] > https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog >