top | item 23234017

Ask HN: Production Prolog in 2020?

131 points| timxor | 5 years ago | reply

Seeker of logic programmers!

70 comments

order
[+] TheUndead96|5 years ago|reply
I think Prolog and logic programming will have a second renaissance. I think at the very least a general artificial intelligence would require a logical inference engine similar to Prolog.
[+] hcarvalhoalves|5 years ago|reply
I don’t think it will come back as AI, the statistical/differentiable approach proved much more powerful given the amount of data.

I think it will come back in programming tools / program synthesis though. There are many use cases for it and not enough people using in production.

[+] Chabsff|5 years ago|reply
I think it's actually the complete opposite. The current biomimetism direction being privileged by the modern A.I. trends is most likely the correct way to achieve "True" A.I.

However, Inference-based A.I. is actually needed to properly tackle many of the business problems that are being thrown at ML systems today. Explainability and bias reduction can probably only be be taken so far with the current approaches, and I suspect that this "so far" is not far enough for many tasks. It's definitely the case from a practical standpoint today.

So inference-based A.I. is due for a comeback indeed, but I'd say AGI is looking like one of the main areas where the current techniques might work.

[+] thom|5 years ago|reply
Do any of the non-artificial intelligences walking around out there contain a logical inference engine similar to Prolog?
[+] ragebol|5 years ago|reply
I'm pretty sure reasoning is important towards that goal, but how that is achieved is much less clear. Perhaps some probabilistic additions at the least.
[+] bitL|5 years ago|reply
I doubt it. Prolog is inherently based on DFS that usually leads to inefficient algorithms. Cut operator then turns any source into an unreadable mess.
[+] jmnicolas|5 years ago|reply
Our pay software at work needs a Prolog engine (SWI). I think it's exactly where it shines : a complex logic with a lot of small rules that would be a nightmare to implement and maintain with a if / else logic.
[+] ianamartin|5 years ago|reply
I implemented something similar to that at a payments company a while back, but not with prolog because I couldn't get buy-in. I wrote a rules engine expressed as SQL tables, and it was absolutely better than if-else or switch. It let us delete thousands of lines of code and also slap on a UI so that the people managing the payments rules could make changes themselves. Highly recommend.
[+] darksaints|5 years ago|reply
At this point, I feel like it is verging into lost knowledge territory, but that use case is almost the exact use case for the Rete Algorithm. As long as your rules fit in memory and are not recursively applied, rule application is an O(1) operation.

https://en.wikipedia.org/wiki/Rete_algorithm

[+] thanatropism|5 years ago|reply
There was a minor hype cycle with SMT solvers in 2019.

For a while I was extremely fascinated by SAT as an encoding for hard problems that somehow had heuristic fast solvers; particularly by SATPLAN, the blocks world, etc.

But there's an useful contrast with Lisp, the other thing everyone within a radius of HN would like to emerge as winner. Lisp is essentially a syntax concept. It isn't particularly opinionated about problems -- on the opposite, it's indefinitely extensible to accomodate nearly everything. So we have Clojure and Hy (a Lisp that superficially imitates Clojure but compiles to the Python AST) and people doing scikit-learn ML on Lisp.

Logic programming, on the other hand, wants problems to be formulated on its terms. It needs the world itself to change to "win big". Of course logic programming problems aren't going to disappear, as sparse linear algebra programs won't. But this isn't a paradigm, it's an application.

[+] felixyz|5 years ago|reply
Prolog-style logic programming is very different from SAT, SMT and Answer Set Programming in this regard. Prolog has the same features that you describe in Lisp. It's homoiconic, infinitely malleable, meta-level programming is trivial, etc. I recommend having a look at:

https://www.metalevel.at/acomip/ (A Couple of Meta-interpreters in Prolog)

and

https://github.com/triska/lisprolog

[+] tluyben2|5 years ago|reply
I really like working with https://mercurylang.org/ ; I think there are a few companies that use it for production software.
[+] thelazydogsback|5 years ago|reply
Seems like it had some traction like 10 years ago. I like the idea of controlling backtracking, but then when I tried it I thought it got a bit verbose w/all the mode decls. I should take a look and see if there's been any changes recently.
[+] CyberFonic|5 years ago|reply
I did some work with SWI-Prolog. It is useful when the problem can be effectively translated into Prolog's preferred form of terms and rules. But the solver mechanism only solves a subset of logical inference needs. Prolog's use of logic in AI should not be conflated with the AI/ML systems which use networks of floating point operations, i.e. not boolean operations.

As always, best to choose the tool / language that best suits the problem.

[+] ghufran_syed|5 years ago|reply
Datomic uses Datalog, a dialect of prolog, that's what I would look at first if I needed prolog in production in 2020.
[+] badtuple|5 years ago|reply
Kind of offtopic, but does anyone know a good resource around implementing a simple prolog/similar language? My previous attempts at learning logic programming have failed, and it just _feels_ like a thing that becomes clear after you've seen how it works under the hood.
[+] Jtsummers|5 years ago|reply
Along with @btwillard's suggestion, check out The Reasoned Schemer, it goes about explaining miniKanren and gives enough information to implement it yourself. It's a fantastic exercise.
[+] carapace|5 years ago|reply
I'm writing a constraint solver-based scheduler for lab work with social distancing. It's going to be used by at least one lab.

(Reminds me I've got to get to work on it! Anybody ping me if you want to help.)

[+] The_rationalist|5 years ago|reply
A tangeant question is: Which non-niche language are having push for integrating a subset of logic programming extensions ?

There was a (unlikely to be merged at least in its current form) proposal for Kotlin -> https://github.com/Kotlin/KEEP/pull/199/files

Maybe LINQ from .NET could be included

There is also chalk from Rust https://github.com/rust-lang/chalk

[+] ahelwer|5 years ago|reply
LINQ is just in-language SQL with type checks, unless I'm ignorant of a bunch of its functionality (which I really hope is true, now).
[+] paloaltokid|5 years ago|reply
Is this related to Datalog also? I've watched a few presentations by Rich Hickey (creator of the Clojure programming language) and I feel like he often name-drops Datalog as a great tool.
[+] tmaly|5 years ago|reply
I have used Prolog in a few professional projects.

I think if they came out with a version in hardware like they use to have lisp machines, it would have much better performance.

[+] felixyz|5 years ago|reply
That was one of the ideas of the Fifth Generation Computer Systems project, started in 1982 :)
[+] _neural_|5 years ago|reply
To the degree that it counts as 'production' Prolog, DFS-Tools -- a toolkit for Distributional Formal Semantics -- is actively used in a number of ongoing scientific projects: https://github.com/hbrouwer/dfs-tools
[+] brudgers|5 years ago|reply
Any system that uses Datalog uses a subset of Prolog. Loosely, this would include systems using Clojure's Datalog. To the degree the goal is logic programming, the looseness is more appropriate. YMMV.