Lurker News
Hi, i am a compsci student that stumbled upon prolog and logic programming during my studies.

While i have seen the basics of vanilla prolog (atoms, predicates, cuts, lists and all that jazz) and a godawful implementation of an agent communication system that works on SICStus prolog. I would like to know more because i think that this language might be a powerhouse in per se.
Since my studies are quite basic in this regards i would like to expand my knowledge on it and kind of specialize myself both in this world and another world (ontologies :D) that i really enjoy.
What's prolog like in 2024? what are you wonderful people doing with it?
thanks from a dumbass :D

Comments (276) 60 threads

Show all comments

Showing thread 49 of 60

evgskv#
I think of Prolog as a general purpose logic programming language and Datalog to be logic programming more focused on data analysis. Data analysis is a very large area, so boundary might get blurry at times.

If your data is in a relational database consider Logica - a Datalog family language that compiles to SQL and runs naturally on SQLite, Postgres, DuckDB and Google BigQuery.
Easy to install, easy to play with in CoLab or any other Jupyter notebook.
Works for data analysis (aggregation, filtering etc) that is commonly associated with SQL, as well as recursive logical querries commonly associalted with Logic programming per-se.
Here is what it looks like for a data-analysis-ish query of finding popular baby names over time:
# Count babies per year.
NameCountByYear(name:, year:) += number :- BabyNames(name:, year:, number:);
# For each year pick the most popular.
TopNameByYear(year) ArgMax= name -> NameCountByYear(name:, year:);
# Accumulate most popular name into a table, dropping the year.
PopularName(name: TopNameByYear());
The classic grand-parent rule looks as usual:
Grandparent(a, c) :- Parent(a, b), Parent(b, c);
Here is a recursive program for finidng distances in a directed graph:
D(a, b) Min= 1 :- Edge(a, b);
D(a, b) Min= D(a, x) + D(x, b);
Links to CoLabs:
Grandparent, ancestor: https://colab.research.google.com/drive/1lujnnUOXsF6VrC9__jV...
Distance in graph:
https://colab.research.google.com/drive/1sOCODHqN0ruxZSx_L-V...
Github repo: https://github.com/EvgSkv/logica