Live data from Hacker News

Ask HN: What are some interesting examples of Prolog?

news.ycombinator.com

61–64 of 64 posts

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

#61
I write Prolog version bulletML in Prolog.

https://github.com/hsk/bulletpl/blob/master/bulletpl/1943_ro...

It is a movement of the rolling fire of CAPCOM shooting game 1943.

Original Bullet ML DSL is XML base, however this version base Edinburgh Prolog format.

http://www.asahi-net.or.jp/~cs8k-cyu/bulletml/index_e.html

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

#62
post #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.

Here's part of a sample sequence: 1) Smarthome gets a notification of a vehicle detected in the driveway 2) sends a request to get an image from the driveway camera 3) gets the image, sends it off for storage and analysis 4) sends it to an image recognition service which returns a description(make/model/color + other info) as JSON 5) receives analysis, matches it to known vehicles and announces the results

The send_display_vehicle_id(Id) in the end actually does a lot, it queries redis for previously announced display type devices, then looks up the capabilities (bit depth, resolution) of each device and formats accordingly then sends the display request for each. Also send_android_notification sends the request to some Java code that initiates a push message to my phone and watch.

None of this is rocket science in terms of Prolog message(MQTTPathAsList, MessageBody) is my general predicate for handling an incoming MQTT message once I've subscribed to it and it's convenient to deal with a MQTT topic path as a list.

message(['Smarthome','Notify', 'vehicle','motion'],_):- log('brain saw vehicle motion'), get_short_timestamp(S), atomic_list_concat([S, ' Vehicle Motion'], NotificationMessage), send_android_notification('Smarthome', NotificationMessage), request_image('alibi4').

request_image(Camera) :- publish(['Smarthome', 'Video', Camera, 'brain', 'request']).

message(['Smarthome','Video', _ ,'brain','response'],Image):- store_image(Image, 'brain'), analyze_image(Image, 'brain').

analyze_image(Image, Id) :- publish(['Smarthome', 'Sighthound', 'analyze', Id], Image).

message(['Smarthome','Vehicle', 'Sighthound'],VehicleJson):- vehicle_id(VehicleJson, Id), get_short_timestamp(S), atomic_list_concat([S, ' brain saw vehicle: ', Id], NotificationMessage), send_android_notification('vehicle', NotificationMessage), send_display_vehicle_id(Id), atom_concat(Id, VehicleJson, Description), atom_concat('brain saw vehicle: ', Description, Message), log(Message).

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

#63
At the public funded project http://vvm-projekt.de we are developing methods for verification and validation of autonomous driving. My team developed an analysis method for information flow in urban intersections. The software is implemented in PROLOG (Logtalk). See paper about here (German, will follow in English soon) https://arxiv.org/abs/2108.00252 and infos about implementation https://www.vvm-projekt.de/fileadmin/user_upload/Mid-Term/VV... and https://www.vvm-projekt.de/fileadmin/user_upload/Mid-Term/VV... (English). The project will be finished mid 2023

Cheers Hans

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

#64
post #58
post #14

Earlier quoted context omitted.

Wow this is the best thing since the Actually Portable Executable source code. https://justine.lol/thun.png How did the author generate those letters?

What color scheme is that? Anyone know?

It's justine256 with PragmataPro. Enjoy! https://justine.lol/justine256-theme.el
Post reply on HN