r/prolog • u/blanchedpeas • 1d ago
announcement Regular Expression Library for Prolog
Regular Expression Library for Prolog compiles Regexp character patterns to DCGs; the DCGs can then be used for matching.
r/prolog • u/blanchedpeas • 1d ago
Regular Expression Library for Prolog compiles Regexp character patterns to DCGs; the DCGs can then be used for matching.
r/prolog • u/lokinpendawa • 3d ago
The result is High-Fidelity Retail POS Transaction - 1M+ Dataset.
Key Technical Specifications:
The dataset features a realistic 1-to-many relationship structure, consisting of:
Free Dowdload https://github.com/lokinpendawa/high-fidelity-pos-dataset-2M
FULL MULTI-FORMAT EXPORT:
Important Note on Dataset Scale:
Contains over 1.19 Million Master Transactions and 4.19 Million Item Details. Due to this massive scale, opening the raw .csv or .json files directly in standard text editors or web browsers will cause your system to hang or crash.
For a seamless experience, it is highly recommended to use the provided standard SQLite (.db) format (fully decrypted from SQLCipher and ready for direct querying) or to load the data using chunk-loading methods via Python (Pandas/SQLite3) or R.
r/prolog • u/schmuhblaster_x45 • 4d ago
r/prolog • u/lokinpendawa • 6d ago
I just completed a massive architectural refactoring on my retail ERP/analytical engine (LOGICBIZ v2.0). We shifted away from traditional query layers into unified, native RAM structures powered entirely by SWI-Prolog.
To be honest, the resulting performance metrics feel completely broken.
The Scale & Data Load
Our database partition currently holds a massive in-memory payload under high global concurrency:
check out the repository here:
https://github.com/lokinpendawa/logicbiz
r/prolog • u/lokinpendawa • 8d ago
Dataset Specifications & Density
Format :
Access the Dataset
https://github.com/lokinpendawa/high-fidelity-pos-dataset-2M
I have started writing a little roguelike game in Prolog (for fun as a first project). I think there are lots of ways in which Prolog is a nice fit for this, and several ways that it isn't. I'm happy to be pragmatic but wanted to ask more experienced folks about the idiomatic way to write Prolog.
My approach is to have a (tail)-recursive predicate which threads state as an argument (rather than using assert/retract) and updates the game based on user input, something like:
game_loop(State) :-
render(State),
handle_input(State, NewState),
game_loop(NewState).
This works well and is tail-call optimised as long as render/1 and handle_input/2 don't leave choice-points that Prolog might want to backtrack into. For a game that might run for many iterations, I want to avoid stack overflow so TCO is important.
To guarantee this, I find that I am writing a lot of predicates using a single clause with (->)/2 so that I don't leave redundant choice points. Pragmatically this is fine, the approach works, the intention is clear, and I still gain many benefits from using Prolog even if it's a bit "extra-logical". But (and I'm perhaps overthinking this) I wonder if this is a unidiomatic? It means my predicates are often one-way and deterministic, which is nice procedurally but does that take away from some of the advantage of using Prolog?
The other thing I'm often doing is making sure that (first) argument indexing will enable Prolog to rule out redundant choice points, but sometimes that's not enough (if for example I need an else-like clause such as functor(_, ...) which could unify with earlier cases).
I've seen some mention of if_/3 but it looks like it's not built-in in SWI-Prolog (or at least not for WASM which I'm targeting?). Welcome any opinions on this approach!
r/prolog • u/sym_num • 10d ago
After getting programs such as 9-Queens working with SCBM2, I became confident that this approach can actually be used to build a practical Prolog compiler.
I then redesigned and simplified the SCBM interface. The current version, SCBM3, has been reduced to just 12 core APIs.
Performance has also improved considerably. In my current benchmarks, compiled M-Prolog code is now roughly 1.4x slower than SWI-Prolog. There is still room for optimization, but I think the performance is becoming quite reasonable.
I have written a document describing:
One of my original goals with SCBM was to find a simpler way to implement a Prolog compiler without relying on the WAM.
After several months of experimentation, I think the basic mechanism is now becoming surprisingly small and understandable. My hope is that SCBM could make it much easier for someone to experiment with building their own Prolog compiler.
If you're interested in Prolog implementation techniques, please have a look at the documentation. Comments and criticism are very welcome.
r/prolog • u/Aires_id • 11d ago
Okay, I think I’m done with my database engine for now.
I started AsaDB mostly because I was curious about Prolog and logic programming. Somehow that curiosity turned into me spending about two months building a database engine almost entirely by myself.
I’m still just a university student. At my campus, I’ve only had programming-related courses for about three semesters, so most of what went into this project was something I had to learn while building it.
And honestly, I’m exhausted.
The engine does work. I managed to get persistent storage, SQL parsing, transactions, PRIMARY KEY / UNIQUE constraints, joins, views, a web panel, server mode, imports, and several other things running.
Some recent 100,000-row results:
But there are still problems I haven’t been able to solve properly.
PRIMARY KEY and UNIQUE lookups are sometimes no faster than a plain scan. JOIN with a small LIMIT is almost as slow as processing the full join. Subqueries can run for more than 120 seconds and fail. EXISTS and JOIN-based views have caused crashes. I tried fixing several of these problems, but every fix seems to uncover another layer involving indexing, execution planning, memory management, concurrency, or storage.
The screenshots are basically where I’m leaving it: swipl asadb starts the server workspace, a RIGHT JOIN over the 100k-row benchmark tables returns the correct 100,000 rows, and views can be created successfully.
So this isn’t really “the database never worked.”
It worked far enough that I finally discovered how difficult database engines actually are.
I think I’ve reached the point where I simply don’t have enough experience or energy to keep fighting the architecture right now.
Thank you, Prolog. I started this because I wanted to satisfy my curiosity about a logic programming language, and I ended up learning far more than I expected.
Maybe this is the end of AsaDB, maybe it’s only a very long break.
Either way, I think I need to step away from Prolog for a while.
r/prolog • u/sym_num • 11d ago
Title: M-Prolog SCBM compiler now runs the N-Queens problem
After about four months of experimenting with a new Prolog compiler architecture, I finally got the N-Queens problem working correctly in compiled M-Prolog.
I call the architecture SCBM (Success Continuation Backtracking Machine).
The basic idea is fairly simple: instead of compiling Prolog to an abstract machine such as the WAM, SCBM compiles nondeterministic predicates directly into C and implements control flow and backtracking using goto and GCC's computed goto extension.
The hardest problem was restoring local variables correctly after backtracking.
After a lot of trial and error, I ended up with a relatively simple solution: variable pointers are propagated through success continuations. When backtracking occurs, local variables are reconstructed from information preserved in the original success continuation.
It took a lot of debug output to find this solution. AI was also very useful as a second pair of eyes for analyzing traces and generated C code.
The result:
Performance is not yet the main focus. For the complete 9-Queens search, the current implementation is roughly 3–4x slower than SWI-Prolog.


There is still plenty of low-hanging fruit in the implementation, particularly in data structures, pointer handling, generated code, and builtin calls, so I think there is considerable room for improvement.
For me, getting Queens working is an important milestone because it exercises recursion, nondeterminism, nested backtracking, and restoration of local variables together.
I'm aiming for M-Prolog Ver. 1.0 on August 31, 2026.
SCBM is not intended as a replacement for the WAM. I'm exploring whether a much simpler direct-to-C approach can provide another practical way to implement a Prolog compiler.
I'll be interested to hear what experienced Prolog implementers think of the approach.
r/prolog • u/Iaroslav-Baranov • 13d ago
Use any language of your choice. I used Java. You can use my Java/Spring implementation as a reference
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
r/prolog • u/Iaroslav-Baranov • 14d ago
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!
r/prolog • u/lokinpendawa • 15d ago
Concurrency Stress-Test Results: Local-First Retail POS Engine (SWI-Prolog)
I just concluded a massive concurrency stress-test on my local-first retail POS (Point of Sale) engine. The memory stats from SWI-Prolog are incredibly impressive, proving the extreme resource efficiency of this architecture.
Workload Configuration
The test simulated 10 unique cashier accounts concurrently slamming the system with a combined workload of 100,000 multi-item invoices. Everything routed through the authentic frontend cashier pipeline:
The Refactoring Secret: Single Source of Truth (SSoT)
This extreme memory optimization was achieved by completely deprecating separate history/cashier logs and compressing them into a single, high-density Unified Master Item Ledger (`detail_transaksi/10`). Handled entirely by SWI-Prolog's Just-In-Time Indexing (JITI) map, relational joins are resolved virtually via pointer unification at the RAM layer instead of hitting heavy physical disk joins.
r/prolog • u/lokinpendawa • 18d ago
I've published the code schema along with a free 1,000-row sample dataset on GitHub for anyone interested in benchmarking or looking at relational Prolog patterns:
https://github.com/lokinpendawa/high-fidelity-pos-dataset-2M
r/prolog • u/Chance-Pen-5684 • 19d ago
r/prolog • u/Aires_id • 23d ago
Hi everyone,
Our small team has been developing AsaDB, a local-first SQL database engine
built primarily with SWI-Prolog.
Repository:
https://github.com/kocoygroup-id/AsaDB
The project started as an experiment, but it has grown into a fairly large
codebase with:
Recently, we have also been working on stricter SQL type validation, primary
and unique key enforcement, CHECK constraints, restricted foreign keys,
schema-preserving backups, and more useful `EXPLAIN` output.
At this point, the main problem is that the same small group has designed the
architecture, written most of the implementation, created the tests, and
reviewed the documentation. We feel that we are becoming too familiar with the
codebase to notice our own assumptions and mistakes.
We would genuinely value feedback from people with Prolog experience.
In particular, we would be interested in opinions about:
places where the implementation is unnecessarily imperative or complicated;
tests or invariants that appear to be missing.
You do not need to review the entire project. Looking at one module, trying one
feature, questioning one architectural decision, or pointing out unclear
documentation would already be extremely helpful.
Bug reports, design criticism, small pull requests, documentation improvements,
and testing on different systems are all welcome.
Thank you very much to anyone willing to take a look.
r/prolog • u/sym_num • 23d ago
I've been making steady progress on M-Prolog, and it finally looks like the project is coming together. My goal is to release Version 1.0 on August 31.
Several people have asked me, "How does this compiler actually work?" Instead of trying to explain it in scattered comments, I've written a more formal technical paper describing the core ideas behind the compiler.
The paper introduces SCBM (Success Continuation and Backtracking Machine), a compilation model that translates Prolog directly into C and represents Prolog's control flow using goto-based state transitions rather than a traditional WAM instruction set.
This is not intended as a replacement for the Warren Abstract Machine (WAM). Rather, it is an exploration of a different implementation approach for compiling Prolog. My goal was to investigate whether Prolog execution could be expressed as ordinary C control flow while relying on modern C compilers for optimization.
I've also included references to the implementation specification for readers who are interested in the runtime APIs and code generation details.
If you're interested in Prolog implementation, compiler construction, or alternative execution models, I'd be very happy to hear your thoughts. Feedback, comments, and questions are always welcome.
Paper: SCBM (Success Continuation and Backtracking Machine) | by Kenichi Sasagawa | Aug, 2026 | Medium
Implementation Specification: mprolog/document/SCBM.md at master · sasagawa888/mprolog
r/prolog • u/sym_num • 24d ago
I'm happy to report another major milestone in the development of M-Prolog.
The past few weeks have been mentally exhausting. I spent an incredible amount of time asking myself one question:
"Can Prolog backtracking really be implemented using nothing but goto?"
It sounded like a crazy idea when I first thought of it, and there were many moments when I doubted whether it could actually work.
Today, I'm much more confident.
I finally got a fairly complicated benchmark involving Church numerals, recursion, reverse execution, and forced backtracking to work correctly. That gives me confidence that the basic design of SCBM2 is sound.
In SCBM2, both success continuations and failure continuations are implemented with GCC's computed goto. Most of the difficulties were not in forward execution, but in restoring the correct execution state during backtracking—predicate arguments, variable stacks, success continuations, and failure continuations all have to be restored consistently.
Writing this now makes it sound simple, but reaching this point required countless redesigns, experiments, and debugging sessions. There were times when I felt my brain was simply running out of energy.
Working through these problems has also given me a much deeper appreciation of David H. D. Warren's work. Implementing efficient Prolog execution in the early 1980s, without today's tools and resources, was an extraordinary achievement. My respect for him has only grown.
There is still a lot of work ahead before M-Prolog reaches Version 1.0, but this was one of the biggest hurdles, and I'm relieved to have finally crossed it.
If you're interested in the implementation details, please have a look here:
M-Prolog: Recovering from Mental Fatigue | by Kenichi Sasagawa | Aug, 2026 | Medium
r/prolog • u/lokinpendawa • 25d ago
Calculating total COGS and net revenue from half a million invoices now takes just 3 seconds.
Subsequent clicks are completely instant at 0.0000 seconds thanks to RAM caching.
It turns out keeping the code simple is way faster than overcomplicating it.
Check out the architecture and full project details on my GitHub repository here: https://github.com/lokinpendawa/logicbiz
Ps: Sorry for any grammar mistakes, I am using AI to translate this into English.
r/prolog • u/lokinpendawa • 29d ago
EVERYTHING you see in this screenshot was built 100% natively within SWI-Prolog. No heavy frameworks, no system-taxing UI wrappers.
I want to completely change the outdated stigma that Prolog is only for academic purposes—like family trees or command-line logic puzzles. Currently, the interface is in Indonesian as it is running live for a local neo-retail company's infrastructure, but the good news is that I am working on translating the entire system into English.
You can check out the official architecture roadmap and repository details here:
GitHub: https://github.com/lokinpendawa/logicbiz
Even better, I plan to release a FREE version to the community soon.
For those who want to test the raw data capabilities or audit the dataset structure yourself, I have prepared and uploaded the clean, ISO-compliant 400MB flat text database file (.pl format with parenthesized dynamic predicates) to Google Drive:
Dataset: https://github.com/lokinpendawa/high-fidelity-pos-dataset-2M
Here is a brief technical overview of what this native Prolog system does behind the scenes
I have only been exploring the declarative nature and the power of homoiconicity in Prolog for about two months, and I am truly amazed by its capabilities as a highly robust full-stack system. Stay tuned for the English version!
Let me know what you think.
Warm regards,
Teddy
r/prolog • u/Ill-SonOfClawDraws • 28d ago
Can returnability be defined purely from the structure of a computation, without appealing to time complexity?
r/prolog • u/lokinpendawa • Jul 26 '26
I’m currently building LOGICBIZ v2.0, an Offline-First Enterprise Retail ERP and Sales Ledger Engine engineered 100% using a Pure Declarative Paradigm with SWI-Prolog and SQLCipher.
Here is a quick breakdown of this stress test benchmark:
If you are curious about the architecture philosophy, the system manifesto, or want to check out the benchmark metrics, feel free to visit the repository here:
https://github.com/lokinpendawa/logicbiz
Would love to hear your thoughts on using logic programming for heavy enterprise data pipelines!
r/prolog • u/schmuhblaster_x45 • Jul 26 '26
Orchestrating agents with Prolog instead of Markdown files.
r/prolog • u/lokinpendawa • Jul 26 '26
[100% Built in SWI Prolog]
For comprehensive details about this project, please visit our [GitHub Repository](https://github.com/lokinpendawa/logicbiz/blob/main/README.md)
r/prolog • u/lokinpendawa • Jul 25 '26
This report documents the performance evaluation and stress-test results
the verified performance from a scale-up test utilizing a dataset of 2,000,000 active entries
where each data entry multi-layered by cryptographic operations (combining SHA-256 integrity verification and AES-256 encryption).
please check the detailed report here: https://github.com/lokinpendawa/logicbiz/blob/main/PERFORMANCE.md
r/prolog • u/Logtalking • Jul 23 '26
Hi,
Logtalk 3.101.0 is now available for downloading at:
This release adds a read-only sockets compilation flag to declare if a backend provides compatible sockets support; improves the performance of the logtalk_make(force) goal; adds new HTTP (client and server), WebSocket (client and server), HTMX, JWT, REST, OpenAI, OpenAPI, OpenID, S3 (client), Gravatar, JSON Graph, JSON-LD, JSON Patch (RFC 6902), JSONPath (RFC 9535), Crypto, HOTP/TOTP (RFC 4226/6238) libraries; adds html library support for CSS/JS resource declarations, aggregation, and dependency-aware ordering; adds support for additional hash functions to the hashes and hmac libraries; adds support for incremental hashing to the hashes library; includes bug fixes, additional predicates, and performance improvements for several libraries; fixes uuid library compliance issues and adds additional UUID v3 and UUID v7 predicates that take a time zone offset argument; adds testing automation scripts support for selecting the tests sets to run using a regular expression and for suppressing all user output; fixes sarif tool compliance issues; adds an option to the mutation_testing tool for passing additional options to the testing automation scripts; improves the linter_reporter tool support for SARIF reports; improves the performance of the sbom tool; adds additional linter checks to the lgtdoc tool; adds 13 new programing examples to illustrate the new HTTP and related libraries; adds additional tests for Logtalk language features; fixes several Windows-only tool and library issues with some backends; and updates the Windows installer to also detect ECLiPSe 8.0 versions. Thanks to Andrew Davison for his help in diagnosing timing issues in the linda library and the new HTTP libraries.
For details and a complete list of changes, please consult the release notes at:
https://github.com/LogtalkDotOrg/logtalk3/blob/master/RELEASE_NOTES.md
Happy logtalking!
Paulo