Live data from Hacker News

Ask HN: What are some interesting examples of Prolog?

news.ycombinator.com

31–40 of 64 posts

Re: Ask HN: What are some interesting examples of Prolog?

#32
I used Prolog at my job to fill out complex regulatory forms required in the financial industry. I have a Perl module that queries an Oracle database and constructs the facts database. This is paired with a set of rules to write out the form elements.

I have one other Prolog project that is part of a tool. It explains the relationship between potentially related people. It is used in financial surveillance.

Re: Ask HN: What are some interesting examples of Prolog?

#34
I use it for reverse engineering unknown struct layouts for DWG classes. A field packing problem.

I'm using picat, a better Prolog dialect, and generate the facts automatically from C to generate the field layouts via picat automatically.

https://github.com/LibreDWG/libredwg/blob/master/examples/AC...

optimization problems as in compilers are extremely natural in Prolog.

Re: Ask HN: What are some interesting examples of Prolog?

#35
I've recently come across "The Eye of Horus", a paper + associated code base [1] analysing attacking transactions on smart contracts using DataLog (a subset of Prolog). Not all of it is written in DataLog, but the vulnerability analysis is - the core component of the framework.

[1] https://arxiv.org/abs/2101.06204

Re: Ask HN: What are some interesting examples of Prolog?

#36
post #20

Not a lot of code but a somewhat different use of Prolog than you're likely to see elsewhere. I used my fork of a MQTT library for Prolog ( https://github.com/sprior/swi-mqtt-pack ) to implement the central controller for my home automation system. The system responds to MQTT events and then coordinates the appropriate action by sending MQTT messages to other home services. Recent versions of SWI-Prolog also support…

That is cool! How compact is code that sets groups of behavior? Can you paste any examples? This seems like one of the really powerful aspects of Prolog. That we can work on the microscopic level, and the computer can prove correctness or find solutions to competing constraints.

Re: Ask HN: What are some interesting examples of Prolog?

#39
Not sure if you'd consider this a "complete application" that is bigger than a "Hello-World-esque example" but I've worked on a Discord bot in SWI Prolog[1] for a while with a friend. It was an interesting experience and although a lot of the work (e.g. SWI has a ready-made library for interfacing with WebSockets and sending out HTTPS requests).

Some interesting applications of Prolog specifically include using predicates to filter messages by certain criteria (e.g. if it was sent by the bot's account or not), being able to hot-reload by invoking the make/0 predicate, and homoiconicity to (in theory) easily evaluate random code supplied by a user.

[1]: https://github.com/prolord-pl/prolord

Re: Ask HN: What are some interesting examples of Prolog?

#40

Alpino is a natural language parser and generator for Dutch, written largely in (SICStus) Prolog and some C/C++: https://github.com/rug-compling/Alpino Even in the age of neural parsers, it's still one of the most competitive parsers for Dutch.

... and Prolog offers traceable brainf*ck:

https://github.com/danieldk/brainfuck-pl

Post reply on HN