How to develop your own implementation of Prolog from scratch in 2026 in one sprint (Guidelines)
▲ 19 r/prolog

How to develop your own implementation of Prolog from scratch in 2026 in one sprint (Guidelines)

Use any language of your choice. I used Java. You can use my Java/Spring implementation as a reference

  1. Week one: dive deep into the standard to create a working prototype
    1. Use Section 6.4 "Tokens" for lexer.
    2. Use Section 6.3 "Terms" for parser. Use Pratt Parser to parse Prolog: it works surprisingly well with it.
    3. If your goal is to understand Prolog, use Section 7.7 "Executing a Prolog goal" as the description of stack-based computation model on which you will base your Prolog engine. It is simple but slow. If your goal is to create a high-performance implementation, you can implement WAM instead from the beginning, but it will take you significantly more time
    4. Keep in mind that the ISO Prolog standard has a lot of minor typos, but every typo is fixable if you put it into context and think about it longer. You don't even need to look up 3 corrigendums (corrections). In fact, they don't cover many important typos so forget about them and just focus on the original 1995 document.
  2. Week two: make your implementation stronger and cover the first 28 problems from the Prolog 99 problems list. They are a perfect benchmark. https://www.ic.unicamp.br/~meidanis/courses/mc336/2009s2/prolog/problemas/

This should be enough! Only 2 weeks (a sprint) and you will have a SUBSTANTIAL boost in understanding Prolog on the deepest level possible, so later you can switch into existing implementations (like SWI Prolog) and see them differently

u/Iaroslav-Baranov — 8 days ago
▲ 26 r/prolog+1 crossposts

I've created TrackLog: a collection of Prolog libraries, examples, and guidelines for building a personal knowledge base in pure logic

  1. TrackLog blurs the boundaries between database administration and programming
  2. TrackLog is based on Formal Grammar (DCG): you will develop your own grammar to accomodate your language needs
  3. TrackLog will help you to create extremely precise and relevant data fuel to feed it to LLMs
  4. TrackLog stands for "Tracking in Logic"
  5. TrackLog libraries are 100% compatible with SWI Prolog dialect and 99% ISO-compatible, so you can port them to another dialect if you need it
  6. My original goal was to create a medical tracker to help people to manage complex illnesses and chronic disorders
  7. Logical Programming is a generalization of functional programming and also a generalization of relational databases. You can see logical programming as a missing glue layer between a database and a program
  8. You can see TrackLog as a second brain to help you capture and analyze data and aid in pure logical decision-making which is free of 100+ cognitive distortions and biases, completely traceable and based on formal logic

Please, use examples.pl as a main guide. I've provided several practical use-cases: Learning Tracker, Item Tracker, Exercise Tracker and Programming Tracker.

Repo: https://github.com/kciray8/tracklog

I'm glad to hear any feedback!

u/Iaroslav-Baranov — 8 days ago

I've found a typo in CLRS Appendix B.5 Trees (definition of tree lacks V != ∅)

Hi!

I've decided to refresh my graph theory using CLRS 4th edition. They define a free tree as a connected, acyclic, undirected graph. None of these conditions prevent us from having null graph with zero vertices and zero edges.

On page 1170, it is proven that for a free tree, |E| = |V| - 1. We can derive contradiction from it: |0| = |0| - 1 -> 0 = -1

Please, confirm it and then I will report it to errata.

reddit.com
u/Iaroslav-Baranov — 26 days ago

I've solved all of the Graph Theory study plan (45 problems) on LeetCode

https://leetcode.com/studyplan/graph-theory/

I have a list of tips for you if you decide to take it:

  1. Keep in mind that this plan is quite challenging. If you didn't take any mathematics for computer science course, you will probably be blocked halfway through. I've taken algorithms-graphs-data-structures course 4 years ago and it basically saved me.
  2. The organization of this plan is good: starting from the easiest topics (traversal/BFS/DFS) and ending with advanced topics (Dijkstra's/MST). However, there is one structural bug: the Cheapest Flights Within K Stops problem doesn't belong at the beginning of the Dijkstra section. I've reported it and maybe the LeetCode team will fix this. For now, just keep in mind that this problem can be cleanly solved with Bellman-Ford in 22 lines of code.

It took me 22 days to finish this study plan

reddit.com
u/Iaroslav-Baranov — 1 month ago

I've solved all of the Graph Theory study plan (45 problems) on LeetCode

https://leetcode.com/studyplan/graph-theory/

I have a list of tips for you if you decide to take it:

  1. Keep in mind that this plan is quite challenging. If you didn't take any mathematics for computer science course, you will probably be blocked halfway through. I've taken algorithms-graphs-data-structures course 4 years ago and it basically saved me.
  2. The organization of this plan is good: starting from the easiest topics (traversal/BFS/DFS) and ending with advanced topics (Dijkstra's/MST). However, there is one structural bug: the Cheapest Flights Within K Stops problem doesn't belong at the beginning of the Dijkstra section. I've reported it and maybe the LeetCode team will fix this. For now, just keep in mind that this problem can be cleanly solved with Bellman-Ford in 22 lines of code.

It took me 22 days to finish this study plan

reddit.com
u/Iaroslav-Baranov — 1 month ago

I lack deep understanding of binary search and it is such a blocker!

I can solve HARD DP/Graph/Backtracking problems: challenging, but it is manageable and I can train my brain. The more I solve it, the better I get at it.

However, the binary search HARD problems are complete blockers for me. I understand the core idea of binary search and how good it is (going from linear to logarithmic complexity). I also know the "monotonic predicate trick" (reduce problem to T T T F F F F F and search on it), but it only helped with a limited amount of problems.

I had a real hope for Binary Search study plan, but was able to solve only 21/42 problems and then got BLOCKED. I just can't connect the problem requirements (description) with binary search and plug it in.

Sorry if my post sound like a copypasta: it is NOT. It is a real problem. I've also encountered problems which require using the binary lifting technique. They also block me because the same idea/same neural pathways are used to solve these (probably).

Is there a magical video or chapter from a textbook, so I can watch/read it and finally GOT the deep understanding after that? My only hope now is to solve 100+ medium problems from https://leetcode.com/problem-list/binary-search/ over a long period of time and just hope that my brain can adapt/neuroplasticity will work for me.

reddit.com
u/Iaroslav-Baranov — 1 month ago

Is it possible to put the entire Leetcode problem set (3977 problems) into a topological ordering?

Some problems are easier than the others and your brain chunks easier problems so you will solve harder problems faster and easier. There are also a lot of composite problems (e.g. DP + BS or adding Trie/UF).

My conjecture is that such topological ordering do exists. Moreover, after we have a brain model of an average human programmer, it will be possible to prove (by structural induction) that the entire Leetcode problem set can be solved with joy and ease if you follow this order.

reddit.com
u/Iaroslav-Baranov — 2 months ago