At work, there was a discussion of using prolog as the backend for a rules engine on a web-app.
How would this get tied into existing systems?
Are there available prolog libraries for other languages allowing the invocation of prolog modules?
At work, there was a discussion of using prolog as the backend for a rules engine on a web-app.
How would this get tied into existing systems?
Are there available prolog libraries for other languages allowing the invocation of prolog modules?
For SWI-Prolog, you could look to Thea2 which has support for SWRL in Prolog and can also be attached to external reasoners via JPL such as HermiT for OWL/SWRL reasoning, or Pellet, etc.
On a personal note, I have used JPL several times in the past to enable web-apps with a SWI-Prolog backend, which works just fine if you intend to program your web app using a language which is executable on a JVM, like Java, Groovy, or Scala, for example. Another alternative would be to hook SWI-Prolog into a C or C++ environment, which I haven't tried for a web-app.
If your web-app is using another development language that doesn't run on a JVM or in C/C++, then this mightn't be the right path for you as it seems to be a bit harder to connect a running SWI-Prolog environment to other language environments. However, that said, we have successfully implemented a SWI-Prolog-to-anything bridge using HTTP before, but this is less than ideal if performance is a necessity.
swi-prolog has a perfectly reasonable HTTP server/ web framework included.
You could talk to it over HTTP.
There are tools for parsing XML/SGML and JSON, and ODBC
I'm not sure exactly what you're looking for, but you may want to look into Yield Prolog , which allows the embedding of Prolog code into programs using Python, C#, or Javascript. There is no API involved. I haven't used this myself (yet), but it may be amenable to what you're trying to do.
I guess an important prerequisite for web embedding, especially on the server side, is multi theading capability of the Prolog system. At least you would probably need this, if you want to serve multiple users concurrently.
You can then opt either for a pure solution, where the pages are generated and maintained by Prolog itself. Or maybe for a mix solution, where the Prolog system is only used for some business logic and another programming language is used for presentation and/or storage.
The following Wiki comparison table gives an overview of Prolog systems and whether they are multi threaded and/or support some web programming:
Comparison of Prolog implementations,
Operating system and Web-related features
For my own take on this problem I have set up a little tutorial that shows the use of the Jekejeke Runtime for server side business logic. Jekejeke Runtime is quite flexible, you can not only have multiple threads, you can also have multiple knowledge bases.
Jekejeke Runtime,
Deployment Methods
The Jekejeke Runtime is for example currently used in a productive sales system, by some custom read/write locks, it allows even remote hot swap of the knowledge base by an administrator without restarting the web context. Unfortunately there is no report yet on that.
Bye
LPA Prolog has been widely used in various commercial web-based applications, most noticeably within Business Integrity's industry-lead document assembly product, DealBuilder
LPA provide various architectures for deliverying web-based applications - some of which are shocased within the VisiRule section on the LPA web-site www.lpa.co.uk
Clive
Some languages make use of a bridge and provide a library for it for example in Python there's PySWIP for single-threaded use, so it doesn't play nicely with web apps. I've found Pengines to be far more versatile.
Pengines are in SWI, they're a way of querying Prolog via HTTP. There's at least a JavaScript, Java, and Python library to interface with them, but it's just a bunch of HTTP requests. Makes it easy to distribute, use as a micro-service, or horizontally scale. Although as anniepoo has witnessed to, a SWI server can handle decent amount of traffic!
Also in the case of JavaScript there's Tau Prolog which compiles to and works within JavaScript.
There's a lot of sense in using a logic language as a rule engine.
© 2022 - 2024 — McMap. All rights reserved.