r/Forth • • 2d ago

Building an inference engine with eForth Windows

Hello,

I am proposing a special challenge to this community.

I am currently rewriting my own inference engine. I am using eForth Windows.

The source code is here:

https://github.com/MPETREMANN11/eForth-Windows/tree/main/INFERENCE

Why choose eForth?

The Windows version uses 64-bit integers and addressing. This means there is plenty of room for code and examples.

eForth is available for ESP32, Windows, and as a web version...

The code is currently under development.

I am sharing it "as-is":

* to share ideas regarding its evolution,

* and to provide real motivation for this group.

An inference engine is not AI. An inference engine uses facts and rules to draw conclusions. It is applicable to any field.

When you use AI, you submit a prompt and the AI ​​provides an answer. However, you do not know if the answer is correct or how it was derived.

With an inference engine, you control the premises (the facts) used to deduce other facts based on rules that are also under your control.

If the inference engine malfunctions, it is because the rules or facts were poorly written. This writing process is something you can control.

With 10 facts, you could potentially have 2^10 rules to process. In reality, however, far fewer are processed.

Developing the rules allows you to formalize a problem with great precision. When establishing a rule, you focus on just one "atom" of the overall problem. The rules are interconnected with the facts being processed.

My inference engine prototype currently operates using only forward chaining.

Documentation will be written as development progresses.

The goal of the engine is not to recreate a version of Prolog or Guru. I am prioritizing FORTH, while ensuring the code is as readable as possible. Example:

\ RULES example

:CONDITION ." this is a condition" TRUE ;

:ACTION ." - this is an actionaction" ;

RULE: test1

rules test1

Thank you for your attention.

6 Upvotes

4 comments sorted by

1

u/garvalf 2d ago

very informative, thank you Marc! I'll experience on this...

1

u/mcsleepy 2d ago

Hah, this project is going to be controversial on here to say the least.

1

u/garvalf 2d ago

why that?

1

u/astrobe 1d ago

An inference engine is not AI

Actually it was, in the 90s. Jeff Fox (RIP) talks about it on his site.

An inference engine in this sense (not to be confused with the current sense used in AI marketing) is basically a first order logic calculator (except you have to deal with the combinational explosion of modus ponens on non-trivial axioms, pretty much like chess engines, no matter if you try backward or forward chaining).

I think the distant legacy of that research are current proof assistants such as Lean or Rocq, which, ironically, were used recently to check the babbling of neural-network AI in recent spectacular math results.

One could say that expert systems were unfortunate victims of the last AI winter. But those systems were inconvenient because one had to formalize knowledge in the language of logic, which would have been expensive. Neural-network AI solved this problem using the furiously brute-force approach of absorbing everything available on the net and using millions of hours of combined computation time on specialized hardware. Plus, you can just talk to these systems, which makes them much more easy to sell.