← Back to list

M-Prolog: The Final Challenge

The development of M-Prolog has finally reached its last major challenge.

Kenichi Sasagawa · 2026-06-28 23:14 · 3 claps · 2.5 min read
#ai #prolog
Open on Medium ↗
Wiki topics: AI · AI · General

M-Prolog: The Final Challenge

The development of M-Prolog has finally reached its last major challenge.

At present, I am deeply focused on implementing a new compiler mechanism that I have named SCBM (Sasagawa Chat Backtracking Mechanism).

Over the past months, I have solved many difficult problems. And now, even the final remaining issue is beginning to reveal a path toward the solution.

Complex Recursive Backtracking

Here is a test program written by Professor Tamura of Kobe University, which I have introduced before.

nat(0).
nat(s(X)) :- nat(X).
plus(0, Y, Y).
plus(s(X), Y, s(Z)) :- plus(X, Y, Z).
times(0, _, 0).
times(s(X), Y, Z) :- times(X, Y, Z1), plus(Z1, Y, Z).
le(X, Y) :- plus(X, _, Y).
lt(X, Y) :- le(s(X), Y).
quot(X, Y, 0, X) :- lt(X, Y).
quot(X, Y, s(Q), R) :- plus(Y, X1, X), quot(X1, Y, Q, R).
dnd(M, N) :- quot(N, M, _, s(_)).
df(s(0), _).
df(s(s(M)), N) :- dnd(s(s(M)), N), df(s(M), N).
prime(s(X)) :- df(X, s(X)).

When running this prime/1 predicate under my newly designed two-dimensional array-based SCBM mechanism, a segmentation fault occurs.

This is currently the final and most difficult bug remaining in the project.

Building Debugging Tools

To analyze the problem, I added a new -d option to the compiler.

This option automatically inserts debug print statements into the generated C code.

The debugging results have shown something important.

Recursive execution itself is working correctly.

The problem appears to occur when the compiler calls the discard API after failure.

Until now, my discard implementation only considered two situations:

  • Returning from recursive execution
  • Failure in a simple conjunction sequence

However, in a complex case like prime/1, an execution path exists that I had not fully considered.

This exposed a weakness in my original design assumptions.

But in a sense, this is good news.

It means I have almost isolated the exact source of the problem.

At last, I can see the exit.

Collaborative Research with AI

During the development of M-Prolog, I have been working together with AI systems such as ChatGPT almost as if they were research collaborators.

Of course, AI is not perfect.

It sometimes produces incorrect analyses and mistaken assumptions.

But even that has value.

When humans think alone for too long, they often become trapped inside loops of their own reasoning.

AI helps break those loops.

Even when AI gives an incorrect answer, it forces me to examine the problem from another angle.

That allows me to escape mental dead ends and deepen my understanding.

In that sense, AI has become a genuine intellectual partner.

My View on the Future of AI

Many people are anxious about the rapid progress of AI.

In countries such as United States and India, concerns about youth unemployment are already becoming serious.

In Japan, stricter labor regulations have slowed this process, but eventually the same changes will come.

Even so, I remain optimistic.

I have great expectations for AI.

AI can dramatically amplify human capability.

Collaborative research between humans and AI could accelerate the discovery of new medicines, advance technologies such as Nuclear Fusion, and transform scientific progress itself.

I have reached this conclusion not through theory, but through direct experience.

I have pushed AI as far as I possibly could in my own work, and I have seen what it can do.

Dynamite was once used as a weapon.

But it also helped humanity by revolutionizing construction and engineering.

AI is no different.

In the long run, I am convinced that AI will bring enormous positive benefits to humanity.

And I believe we are only beginning to discover what becomes possible when human intelligence and artificial intelligence begin thinking together.


메타데이터
post_id
6a9799f4eec4
slug
m-prolog-the-final-challenge-6a9799f4eec4
url
https://medium.com/@kenichisasagawa/m-prolog-the-final-challenge-6a9799f4eec4
canonical_url
https://medium.com/@kenichisasagawa/m-prolog-the-final-challenge-6a9799f4eec4
author_url
https://medium.com/@kenichisasagawa
status
ok
fetched_at
2026-07-13 06:23:13